Changing font size when using julia-mono-listings

Hi, folks

anybody knows how to change the font size when using julia-mono-listings to write Julia codes in articles and books?

The default looks too big for two-columns typesetting. The standard LaTeX commands (\small, \scriptsize, etc.) do not work.
If you have a working solution, please show here a small complete script.

Thanks!

I assume you’re talking about GitHub - mossr/julia-mono-listings: LaTeX listings style for Julia and Unicode support for the JuliaMono font …

One way you can get smaller text is to use tiny rather than small. So you could edit the file julia-mono-listings.sty and copy the \lstdefinestyle{julia} ... definition, then change the basic style to say \tiny:

\lstdefinestyle{juliatiny}{
    backgroundcolor  = \color[HTML]{F2F2F2},
    basicstyle       = \JuliaMonoRegular\tiny\color[HTML]{19177C},
   ...

Now you have a new style called juliatiny, which you can use alongside the existing julia style:

\LaTeX source:

\begin{document}

This is some code.

\begin{lstlisting}[language=JuliaLocal, style=julia]
using Luxor
@svg begin
    sethue("red")
    randpoint = Point(rand(-200:200), rand(-200:200))
    circle(randpoint, 2, :fill)
    sethue("black")
    foreach(f -> arrow(f, between(f, randpoint, .1), 
        arrowheadlength=6),
        first.(collect(Table(fill(20, 15), fill(20, 15)))))
end
\end{lstlisting}

That code was small.

\begin{lstlisting}[language=JuliaLocal, style=juliatiny]
using Luxor
@svg begin
    sethue("red")
    randpoint = Point(rand(-200:200), rand(-200:200))
    circle(randpoint, 2, :fill)
    sethue("black")
    foreach(f -> arrow(f, between(f, randpoint, .1), 
        arrowheadlength=6),
        first.(collect(Table(fill(20, 15), fill(20, 15)))))
end
\end{lstlisting}

That was tiny.

\end{document}

I couldn’t find any sizes other than small and tiny anywhere - perhaps that’s all you’re allowed to do?

(Disclaimer - I know very little about \LaTeX, and don’t really like what little I know… :slight_smile: )

To fix the white lines showing up with \tiny, you can add the following line to the lstdefinestyle:

\lstdefinestyle{julia}{
    % other settings
    lineskip=2pt
}