Skip to content

LaTeX listings style for Julia and Unicode support for the JuliaMono font

License

Notifications You must be signed in to change notification settings

mossr/julia-mono-listings

Repository files navigation

julia-mono-listings

A custom Julia language style for the LaTeX listings package, and Unicode support for the JuliaMono font in a lstlisting environment.

Note, we use lualatex for compilation.

Example

Typesetting the Thompson sampling algorithm from BeautifulAlgorithms.jl.

  • See template on Overleaf (go to "Menu" ⟶ "Copy Project", must be logged in).

The LaTeX document:

\documentclass[11pt]{article}

\usepackage{julia-mono-listings}

\lstdefinelanguage{JuliaLocal}{
    language = Julia, % inherit Julia lang. to add keywords
    morekeywords = [3]{thompson_sampling}, % define more functions
    morekeywords = [2]{Beta, Distributions}, % define more types and modules
}

\begin{document}
\begin{lstlisting}[language=JuliaLocal, style=julia]
using Distributions

function thompson_sampling(𝛂, 𝛃, apply; T=100)
    for t in 1:T
        𝛉 = rand.(Beta.(𝛂, 𝛃))
        x = argmax(𝛉)
        r = apply(x)
        𝛂[x], 𝛃[x] = (𝛂[x] + r, 𝛃[x] + 1 - r)
    end
    return Beta.(𝛂, 𝛃)
end
\end{lstlisting}
\end{document}

Output PDF:

License

The font license is located here, and the license for this repo is located at LICENSE.md.

About

LaTeX listings style for Julia and Unicode support for the JuliaMono font

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages