I am trying to write a short summary of basic loop functions used in visual basic for my fellow students. I have found the listings package to color the keywords and have already defined all the parameters and additional keywords. I am also using the inline listings for faster and easier writing.
Now, I would like to include such inline listings in another listings caption, like so:
Code: Select all
\documentclass{book}
\usepackage{listings}
\usepackage[dvipsnames]{xcolor}
\lstset{ language=[Visual]Basic,
keywordstyle=\color{blue}, commentstyle=\color{ForestGreen}, stringstyle=\color{Maroon},
basicstyle=\ttfamily\normalsize,
frame=lines, showspaces=false, showstringspaces=false,
tabsize=3,
aboveskip=10pt,
belowskip=10pt,
lineskip=3pt,
numbers=left, numberstyle=\tiny, stepnumber=1, numbersep=5pt
morekeywords={Or, Loop, Until, To, As, Single, Module, Console, Double, ByVal}}
\lstMakeShortInline[basicstyle=\ttfamily\normalsize]{\|}
\begin{document}
Here, we can see an example of the |If| loop implementation with the |ElseIf| and |Else| statements.
\begin{lstlisting}[caption={|If| loop with |Else If| and |Else|},label=ifloop]
If <cond> Then
<code>
ElseIf <cond> Then
<code>
Else
<code>
End If
\end{lstlisting}
\end{document}
Code: Select all
! Argument of \lst@temp has an extra }.
<inserted text>
\par
l.24 ...p with |Else If| and |Else|},label=ifloop]
Cheers,
Stefan