2

I've defined | as a "short inline character", using

\lstMakeShortInline|

I'd like to use that delimiter to typeset inline code in a footnote or a caption, e.g.

\footnote{Java uses the |break| keyword...}.

However, upon compilation, I get the following error:

Argument of \lst@temp has an extra }.

How can I overcome this problem?

3
  • I did not get any error running this \footnote{Java uses the |break| keyword...}. I could not understand what you are trying to do with inline listing. I thought you want to create in line list like 1.a 2.b 3.c etc in footnote. can you clarify more
    – Aku
    Jan 23, 2011 at 16:43
  • @Aku: he is using the listings package. It works like verbatim but it also "highlights" the code according to the some programming language dependent rules. Jan 23, 2011 at 17:10
  • Please add a complete (with preamble) minimal example that illustrates your problem.
    – Caramdir
    Jan 23, 2011 at 17:55

3 Answers 3

1

Footnotes, by default, cannot contain "naked" verbatim content. However, loading the bigfoot package, for instance, will allow you to use a single-character shorthand for inline listings (such as |) in footnotes without any problem.

Typesetting an inline listing in a caption using a single-character shorthand is more difficult; see, for instance, verb inside lstlisting caption. You're probably better off using \lstinline instead.

enter image description here

\documentclass{article}

\usepackage{lipsum}

\usepackage{bigfoot}
\usepackage{listings}
\lstMakeShortInline[language=Java]|
\newcommand\inlineJava[2][]{\lstinline[language=Java,#1]+#2+}

\begin{document}

\begin{table}[tbp]
... some table ...
\caption{\inlineJava{break}}
\end{table}
\lipsum[1-3]

Here is some tidbit about |break| but that's not the whole story.%
\footnote{Java uses the |break| keyword.}
\end{document}
0
1
\documentclass{article}
\usepackage{listings}
\begin{document}
a\footnote{Java uses the \lstinline|break| keyword.}
\end{document}

Works. If you're trying to do something different, please update your question with a minimal example as Caramdir suggested.

0

See How to include verbatim in a figure caption?

1
  • That works for verbatim, actually, the fancyvrb package. The question is about listings, which does more than verbatim. According to the listings manual, the listings package provides some sort of interface to the fancyvrb package, maybe that could be used. However, I really do not understand that part of the manual. It is not clear to me what is the interface supposed to do, and how would one go about using it. Jan 23, 2011 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .