4

First, here is some code that works fine:

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\begin{document}
\lstinline[language=algol,keywordstyle=\color{blue}]{int a}
\end{document}

This uses the algol 68 dialect and it works fine. Now I am going to replace int with integer in the code which requires algol 60 dialect for proper syntax highlighting.

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\begin{document}
\lstinline[language=[60]algol,keywordstyle=\color{blue}]{integer a}
\end{document}

Obviously this does not work due to [...] within [...]. I get this error:

Runaway argument?
{integer a} \end {document}

How do I specify the language dialect within \lstline option?

1 Answer 1

3

TeX sees the ] in [60]algol as the closing bracket for the optional argument so, putting it differently, what it understood was that the optional argument was language=[60 and chaos ensued. Hide the [60]algol inside a pair of {...}:

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\begin{document}
\lstinline[language={[60]algol},keywordstyle=\color{blue}]{integer a}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .