[texhax] listings options
Neal H. Walfield
neal at walfield.org
Tue Jan 3 15:54:20 CET 2012
Hi,
I'm using the listings package to typeset some code. I have some
short snippets that I'm including inline and some longer examples that
I put in floats. I want to apply different options to each of these.
For instance, I want the floating listings to have line numbers, but
the inline listings shouldn't. Further, the inline listings should be
slightly indented, but the floating listings shouldn't be.
I thought I'd do the following:
\usepackage{listings}
\newcommand{\lstfloatsettings}{float, numbers=left}
\newcommand{\lstinlinesettings}{xleftmargin=4ex, xrightmargin=4ex}
\lstset{
columns=fullflexible,
% Don't use visible spaces in strings.
showstringspaces=false,
basicstyle=\small,
captionpos=b,
frame=single,
}
But, that doesn't work:
\begin{lstlisting}[\lstfloatsettings, label=lst:example]
...
\end{lstlisting}
=>
! Package keyval Error: float, numbers=left undefined.
See the keyval package documentation for explanation.
Type H <return> for immediate help.
...
Any ideas or suggestions for a better approach?
Thanks,
Neal
More information about the texhax
mailing list