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.
General ⇒ lstlisting and summary entry
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
Of course it does. And the listings manual shows that quite clearly.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. […]
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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10