1

How to highlight particular ranges of lhs2TeX code in beamer?

Naive example (to be preprocessed with lhs2TeX --agda):

\documentclass{beamer}
%include agda.fmt
\begin{document}
\begin{frame}
\begin{spec}
somefunction :  {-"\begin{alertenv}"-}importantaspect{-"\end{alertenv}"-}
                secondline
\end{spec}
\end{frame}
\end{document}

Compiling such a snippet fails with:

./test.tex:308: Incompatible glue units.
\reset@color ->\beamer@lastskip =\lastskip 
                                           \edef \beamer@lastskiptexta {\the...
l.308 \end{frame}
1

In Agda mode, the alerted region contains an occurrence of \;, as you can observe if you look at the generated code:

\>[17]{}\begin{alertenv}\Varid{importantaspect}\;\end{alertenv}{}\<[E]%

This is triggering the error (it's a muskip and apparently something tries to put it into a normal skip register, leading to the incompatibility error; however, I don't currently completely understand who's responsible). One can argue that lhs2TeX shouldn't put the skip there in the first place.

I can see two workarounds.

(1) Put another skip in that's easier to digest:

somefunction :  {-"\begin{alertenv}"-}importantaspect{-"\hskip0pt\end{alertenv}"-}

(2) Avoid the skip from being inserted by using a different formatting mechanism, for example

%format Importantaspect = "\alert{" importantaspect "}"

and then

somefunction :  Importantaspect
2
  • I updated the question with a minimally complete example. Two aspects were missing from the original question: A second line and --agda.
    – Helmut
    Mar 11 '14 at 8:11
  • I've adapted the answer.
    – kosmikus
    Mar 11 '14 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.