gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] Rendering Modula-2 source code within LaTeX documents


From: Benjamin Kowarsch
Subject: [FYI] Rendering Modula-2 source code within LaTeX documents
Date: Fri, 3 Jul 2020 19:17:26 +0900

I have been LaTeX-ifying the M2R10 specification, using the Listings package to make
LaTeX render Modula-2 source code within the document.

I then noticed that the Modula-2 language definition included with the Listings package
isn't up to scratch. It covers PIM only, and it renders all predefined identifiers as reserved
words. Even so some predefined identifiers are missing, for example NEW and DISPOSE.

I have then made three language definitions for the Listings package, one each covering
PIM, ISO and R10, and uploaded them to Github in my repo for syntax highlighting stuff.

https://github.com/trijezdci/M2-Syntax-Colour/tree/master/LaTeX

This repo also has a wiki page with instructions how to use the files and an example.

https://github.com/trijezdci/M2-Syntax-Colour/wiki#modula-2-syntax-highlighting-in-latex

I tried to define a style where reserved words and predefined identifiers are rendered
in the Algol style, lowercase bold either with/without underline or upright/italic.

Unfortunately, the Listings styles are what LaTeX calls fragile, which means there
are certain commands that simply cannot be used with them and the \MakeLowercase
command is one on which the Listings package chokes. There may be a way to work
around that using a \protect command but this is one of those areas of LaTeX that is
extremely cumbersome and it is quite time consuming to learn the inner workings of
TeX/LaTeX, so I have left this alone for now. If anyone on the list happens to have a
TeX/LaTeX expert in the family, maybe they can take a look at this ;-)

Otherwise, it is probably good enough as it is. Feel free to reuse.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]