GeneralComma in caption (listing package)

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
-Robin-
Posts: 31
Joined: Tue May 20, 2008 3:07 pm

Comma in caption (listing package)

Post by -Robin- »

I'm trying to have a caption containing a comma in combination with the listing package, e.g.

Code: Select all

\lstinputlisting[caption=a caption, containing a comma, label=a label]{inputprogram.java}
Since the part between the [] is a comma-separated key-value list, the listing package expects a key after the comma in the caption.

So I'm looking for another way to write a , so that the listing package doesn't recognize it as a comma.

Any hints, clues, ... are welcome

Recommended reading 2024:

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

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

-Robin-
Posts: 31
Joined: Tue May 20, 2008 3:07 pm

Comma in caption (listing package)

Post by -Robin- »

Hmm, this was a rather stupid question. It is solved by putting the caption between {}

Code: Select all

\lstinputlisting[caption=a caption, containing a comma, label=a label]{inputprogram.java}
should thus be replaced by

Code: Select all

\lstinputlisting[caption={a caption, containing a comma}, label=a label]{inputprogram.java}
and everything works again
Post Reply