4

I have some cites in my captions. But I do not want to appear them in the table of figures or listings. With figures I managed to display an different caption like this:

\begin{figure}
  \centering
  \includegraphics[width=0.55\linewidth]{images/FIPA_Message-Transport-Reference-Model}
  \caption[FIPA Message Transport Reference Model]{FIPA Message Transport Reference Model (\cite{FIPA2000}).}
  \label{fig:FIPA_Message-Transport-Reference-Model}
\end{figure} 

But with lstlisting I have some troubles because the caption is an option of the listings and that seems not to have an optional caption label.

\begin{lstlisting}[ language=Scala,
label={lst:Publisher},
caption={Publisher notify\cite{Zenger2013}}] 
  protected def publish(event: Evt) {
    filters.keys.foreach(sub =>
      if (!suspended.contains(sub) && filters.entryExists(sub, p => p(event)))
        sub.notify(self, event)
    )
  }
\end{lstlisting}

Any Ideas how to solve this? Thanks in advance!

8

This is covered in Section 4.9 of the listings documentation; you can use

caption={[short caption]long caption}

Here's a complete MWE to demonstrate:

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{article}
\usepackage{listings}


\begin{document}

\lstlistoflistings
\begin{lstlisting}[ 
label={lst:Publisher},
caption={[caption for lol]Publisher notify\cite{Zenger2013}}] 
  protected def publish(event: Evt) {
    filters.keys.foreach(sub =>
      if (!suspended.contains(sub) && filters.entryExists(sub, p => p(event)))
        sub.notify(self, event)
    )
  }
\end{lstlisting}

\end{document}
| improve this answer | |

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.