Listings: Inline text too small in headlines

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{listings}

\lstdefinestyle{General} {
basicstyle=\small\ttfamily
}

\lstset{style=General}

\begin{document}

\chapter{MyChapter with some \lstinline|inline text|}
Here is some text with some \lstinline|inline text|

\end{document}


I am using the \lstinline very often in my texts. The font size should be \small within these texts. But sometimes I have to use the \lstinline in my chapter headlines. Of course now there are small too which looks weird. How can I change the fontsize only for these chapter headers?

• Why don't you use simply \texttt{inline text} in the header? verbatim commands like \lstinline doesn't work well in the arguments of other commands anyway. – Ulrike Fischer Feb 22 at 11:14
• @UlrikeFischer great idea. But now it looks too heavy. Is there a way to make it one size smaller than the other text (that's the reason why I make inline text size=small at default: For me one size below the rest looks much better...) – S-Man Feb 22 at 12:48
• in your example it doesn't look to heavy. Are you using other fonts in your real document? Then you should better ask a new question how to scale down the tt-font so that it matches. – Ulrike Fischer Feb 22 at 12:57
• @UlrikeFischer I see, it's the inconsolata package I included which makes it look heavy. The question now is: Can I disable the inconsolata at headlines for texttt? – S-Man Feb 22 at 13:06
• That's a new question, so ask a new question. – Ulrike Fischer Feb 22 at 13:20

\lstinline has an optional argument:

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{listings}

\lstdefinestyle{General} {
basicstyle=\small\ttfamily
}

\lstset{style=General}

\begin{document}

\chapter{MyChapter with some \lstinline[basicstyle=\Huge\ttfamily]|inline text|}
Here is some text with some \lstinline|inline text|

\end{document}


According to the documentation:

\lstinline has an optional argument? Yes. And from this fact comes a limitation: you can’t use the left bracket [ as delimiter unless you specify at least an empty optional argument as in \lstinline[][var i:integer;[. If you forget this, you will either get a “runaway argument” error from TeX, or an error message from the keyval package.

• In this example it works. But for some reason in my whole document at one point the compiler calls "basicstyle undefined in families lst". It works for a certain chapter size but at one point this error appears. I think I could go with the solution of @UlrikeFischer. Thanks nevertheless – S-Man Feb 22 at 12:46