Generallstlisting and summary entry

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
manoelcampos
Posts: 1
Joined: Sat May 21, 2011 4:44 pm

lstlisting and summary entry

Post by manoelcampos »

Hello, in other latex commands like \section, I can define a caption and a summary entry using:

\section[Summary Entry Text for the Section]{Section Caption}

I would like to do the same for a lstlisting command.
I'm using the command as below:

\begin{lstlisting}[caption=My First Lua Application: The classic Hello World Sample, label=list:mycode, language=lua]
print('Hello world!!')
\end{lstlisting}


I tried to use the [] to define the summary entry but it didn't work with lstlisting. Are there any way to do this?

Thank you.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

lstlisting and summary entry

Post by localghost »

manoelcampos wrote:[…] I'm using the command as below:

\begin{lstlisting}[caption=My First Lua Application: The classic Hello World Sample, label=list:mycode, language=lua]
print('Hello world!!')
\end{lstlisting}


I tried to use the [] to define the summary entry but it didn't work with lstlisting. […]
Of course it does. And the listings manual shows that quite clearly.

Code: Select all

\begin{lstlisting}[%
  caption={[My First Lua Application]My First Lua Application: The classic Hello World Sample},
  label={list:mycode},
  language=lua
]
print('Hello world!!')
\end{lstlisting}

Best regards and welcome to the board
Thorsten
Post Reply