# How can I 'set off' a \lstinline portion of text?

See the question below:

\documentclass{article}
\usepackage{listings}

\begin{document}
Here is some text where I would like to talk about a particular
variable called \lstinline|var|.  How can I visually set off
\lstinline|var| as something special without being too ridiculous?
\end{document}


Current output as demonstration:

How can I change inline listings without also changing the style for displayed listings?

-

Usually it's enough to use mono-spaced font (and perhaps a smaller font size) and this can be done using the optional argument for \lstinnline or, better yet, defining a short variant with the desired options already included:

\documentclass{article}
\usepackage{listings}

\lstMakeShortInline[basicstyle=\small\ttfamily]|

\begin{document}
Here is some text where I would like to talk about a particular
variable called \lstinline[basicstyle=\small\ttfamily]|var|.  How can I visually set off
\lstinline[basicstyle=\small\ttfamily]|var| as something special without being too ridiculous?

Here is some text where I would like to talk about a particular
variable called |var|.  How can I visually set off
|var| as something special without being too ridiculous?

\end{document}


And, of course, you can also add some other properties (a color, for example):

\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}

\lstMakeShortInline[basicstyle=\small\ttfamily\color{cyan}]|

\begin{document}
Here is some text where I would like to talk about a particular
variable called \lstinline[basicstyle=\small\ttfamily\color{cyan}]|var|.  How can I visually set off
\lstinline[basicstyle=\small\ttfamily\color{cyan}]|var| as something special without being too ridiculous?

Here is some text where I would like to talk about a particular
variable called |var|.  How can I visually set off
|var| as something special without being too ridiculous?

\end{document}


-
I should probably add to the original question that I would not like to also change the style for displayed listings; my apologies. – Sean Allred Feb 27 '14 at 4:53
@SeanAllred No need to apologize :) Please see my updated answer. – Gonzalo Medina Feb 27 '14 at 4:59

Another option is to define a new style, for example

\lstdefinestyle{inline}{%
basicstyle=\small\ttfamily\color{red}
}


and use it for \lstinline regardless of the character used to encase the listing:

\lstinline[style=inline]|var|
\lstinline[style=inline]!var!


MWE:

\documentclass{article}
\usepackage{listings,xcolor}

\lstdefinestyle{inline}{%
basicstyle=\small\ttfamily\color{red}
}

\begin{document}
Here is some text where I would like to talk about a particular
variable called \lstinline[style=inline]|var|.  How can I visually set off
\lstinline[style=inline]!var! as something special without being too ridiculous?
\end{document}


Output:

-