lhs2tex
lhs2tex copied to clipboard
subst spec directive ignored
I would like to experiment with some visual difference between spec and code blocks (in my lecture notes for the DSLsofMath course) but it seems like the %subst spec
directive is not honoured. See minimal example below. Is there an easy fix / workaround?
\documentclass{article}
%include polycode.fmt
%subst spec a = "spec starting'n" a "spec ending'n"
%subst code a = "code starting'n" a "code ending'n"
\begin{document}
\begin{spec}
\end{spec}
\begin{code}
\end{code}
\end{document}
Command line: lhs2TeX --poly q.lhs > q.tex
Expected output:
spec starting
spec ending
code starting
code ending
Actual output:
code starting
code ending
code starting
code ending
Unfortunately, spec
and code
are treated in completely the same way when in poly mode, and there is no subst spec
directive, so the current behaviour is as intended.
It would be relatively easy to change this, but it would not be an entirely backwards-compatible change. (If someone redefines %subst code
in their document, then if I introduce %subst spec
, any spec-block in their document would be formatted incorrectly. Aliasing of %subst
-directives is currently not supported either.) I'm always extremely cautious of such changes.
The only workaround I can think of is to add more context on the LaTeX side and write something like:
\begin{document}
\spec
\begin{spec}
\end{spec}
\begin{code}
\end{code}
\end{document}
where \spec
is a normal TeX command switching the style of the next code block. You'd then redefine %subst code
to map to an environment that looks whether the \spec
-switch is currently set and does something different depending on that, and also re-sets the switch.