Skip to content
Benjamin Kowarsch edited this page Jul 3, 2020 · 8 revisions

Modula-2 Syntax Highlighting

Modula-2 Syntax highlighting in LaTeX


Copy-paste or include the contents of one of the following files into your LaTeX document, depending on the Modula-2 dialect you want to render:

Adjust the line \setfont{DejaVuSansMono-TLF} to use the desired font in which the source should be rendered.


For any Modula-2 source code section in your LaTeX document, create a Modula-2 environment:

(* your source code goes here *)

This will create a square frame with a thin grey border and faint grey background and render your Modula-2 source code using the chosen font with syntax highlighting.

  • Reserved words are rendered in bold
  • Predefined identifiers are rendered normal
  • String literals are rendered in dark grey
  • Comments are rendered in grey italic
  • Pragmas are rendered in bold grey (ISO and R10 dialects only)


A statement of the form

FOR value-- IN [1..99] OF CARDINAL DO
  WRITE value, `` bottles of beer, take one down and pass it around.\n``
END; (* FOR *)

iterates over subrange \inl{[1..99] of type \inl{CARDINAL} in descending order.

will render

rendering sample

Clone this wiki locally