[luatex] Computer code listings in attractive labeled boxes

Siep Kroonenberg siepo at cybercomm.nl
Thu Feb 8 13:54:25 CET 2018


On Wed, Feb 07, 2018 at 05:55:01PM -0500, lloyd at writersglen.com wrote:
> Hi Siep,
> 
> Many thanks for your response.
> 
> Unfortunately, the listings package doesn't give us quite what we need. It provides formatting and token lighting. We need to mark arbitrary sequences of code to emphasize code changes from previous listings.
> 
> I've attached an examples of what we have so far, both screen shots and LaTex code:
> 
> listing_9.2.png shows our original attempt at styling code lists.
> listing_3.8.png shows our more recent attempt
> listings.txt shows code for both approaches
> 
> Our problem is that we need to convert several hundred such listings into a visually attractive style.

Example document:

\documentclass{article}
\usepackage{color,listings}

% turning off syntax highlighting:
\lstset{%
  basicstyle=\small\ttfamily\mdseries,
  keywordstyle=,
  identifierstyle=,
  commentstyle=,
  stringstyle=,
  showstringspaces=false,
  moredelim=[is][\itshape]{/*}{*/},
  moredelim=[is][\color{red}]{/+}{+/}}

\begin{document}
\begin{lstlisting}
foreach $l (@ll) {
  print "$l\n";
}
\end{lstlisting}

>From file:
\lstinputlisting{example.lst}
\end{document}

Listing file example.lst with some markup:

foreach $l (@ll) {
  print "$l\n";
}
our $var1;
my $var2;

/*
print "$var1\n"if defined $var1;
print "$var2\n"if defined $var2;
*/

print "$var1\n"if /+defined $var1;+/
print "$var2\n"if defined $var2;

Somehow, replacing \itshape with \bfseries did not work.

-- 
Siep Kroonenberg


More information about the luatex mailing list