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

Modula-2 Syntax Highlighting

Modula-2 Syntax highlighting in LaTeX

Setup

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.

Usage

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

\begin{Modula2}
(* your source code goes here *)
\end(Modula2)

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)

Example

A statement of the form

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

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

will render

rendering sample

Clone this wiki locally