2

I am trying to use \lstinline but it does not work as expected:

\documentclass{scrreprt}

\usepackage{color, listings}

\lstset
{
    language=C,
    keywordstyle=\color{blue},
}

\lstset{language={[x86masm]Assembler}}

\begin{document}

    \begin{lstlisting}[language = C]            
#pragma pack(1)
    \end{lstlisting}

    Das \lstinline!#pragma pack(1)! dient dazu...

\end{document}

In lstliting #pragma is correctly shown in blue color but with \lstinline it stays black. What is the problem?

Thank you!

  • (1) Welcome, (2) as always on this site, please provide a full minimal example including document class, premable, sample document body. That makes it a lot easier for us to help you. – daleif Dec 3 '15 at 13:56
  • 1
    @daleif (1) Thank you, (2) changed that :) – honiahaka10 Dec 3 '15 at 14:11
  • 1
    \lstinline still needs to be told the language in order to highlight correctly, just like you have done with lstlisting: \lstinline[language=C]!#pragma pack(1)!. – Paul Gessler Dec 3 '15 at 14:25
2

Since the last global (document-level) setting of language was {[x86masm]Assembler}, all listings package code commands/environments use this unless another language is specified on a per-listing basis.

Use \lstinline[language=C]!#pragma pack(1)! to use the highlighting rules for the C language for this particular piece of inline code.

Alternatively, if most of the code in the document is C code, remove the line \lstset{language={[x86masm]Assembler}} and use local language overrides for language={[x86masm]Assembler} as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.