TransWikia.com

How can I reduce the font size of an algorithm?

TeX - LaTeX Asked by x-rw on March 3, 2021

I want to reduce the font size of my algorithm in this code:

begin{small}
medskip
begin{lstlisting}[language=Java,escapechar=|,caption= loop main]

 for (double x = 1 + 1; x <= 2 - 1; x++) {
 }
 
end{lstlisting}
{small source: unknown dotsparmedskip}  % <--- defined "in-line"
end{small}

What I tried has not worked.

One Answer

You can decrease the font size (as well as set fontface and other font characteristics) through the parameter basicstyle in lstlisting environment:

begin{lstlisting}[language=Java,escapechar=|,caption= loop main,basicstyle=scriptsize]
    
    for (double x = 1 + 1; x <= 2 - 1; x++) {
    }
    
end{lstlisting}

Or you can set the font sizes globally in lstset{} command, for example:

lstset{
   basicstyle=scriptsize,
   commentstyle=scriptsizesl,
   escapechar=|
}

Correct answer by Vladimir on March 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP