0

When I use the word base inside \lstinline{} to highlight it as inline code, I get an error, followed by warnings that are not there, if the error is not there:

Package xcolor Error: Undefined color `yac'. \lstinline{base}
Usage of package `parskip' together(scrreprt) with a KOMA-Script class is not recommended.
\float@addtolists detected!(scrreprt) Implementation of \float@addtolist became(scrreprt) deprecated in KOMA-Script v3.01 2008/11/14 and(scrreprt) has been replaced by several more flexible(scrreprt) features of package `tocbasic`.
Overfull \hbox (0.64577pt too wide) in paragraph
\float@listhead detected!(scrreprt) Implementation of \float@listhead became(scrreprt) deprecated in KOMA-Script v3.01 2008/11/14 and(scrreprt) has been replaced by several more flexible(scrreprt) features of package `tocbasic`.

I get this error when I use \lstinline{base}, \lstinline{<base>} or \lstinline{a base}, but not with \lstinline{Base} or \lstinline{abase}. So I'm whondering, is base a reserved word? How can I highlight it with the listings package? Btw. base is an HTML element.

MCRE:

\documentclass{scrreprt}

\usepackage[dvipsnames]{xcolor}
\usepackage{listings}

\lstset{
    emph={square}, 
    emphstyle=\color{blue}\texttt,
    emph={[2]root,base},
    emphstyle={[2]\color{yac}\texttt}
}

\begin{document}
    No error: \lstinline{Base} 
    
    Error: \lstinline{base}
\end{document}
1
  • 1
    The problem is not related ith base or Base. It is related with hoy you define lstset
    – scd
    Oct 9, 2020 at 11:43

1 Answer 1

1

It his what you are looking for?

\documentclass{scrreprt}

\usepackage[dvipsnames]{xcolor}
\usepackage{listings}

\lstset{
    emph={square}, 
    emphstyle=\color{blue}\texttt,
    emph={[2]root,base},
    emphstyle={[2]\color{red}\texttt},
}

\begin{document}
    No error: \lstinline{square} 
    
    Error: \lstinline{base}
\end{document}

Result:

enter image description here

1
  • Ok, I get it. Little background: The code is from a template I have to use. It looks like the authors wanted to highlight the words square, root and base differently. And as base needs the color yac, that does not exist, there was an error thrown whenever I used it. Actually, I do not need this extra highlighting at all. So I deleted all the emph* lines. Thanks for pointing me to this. Oct 9, 2020 at 13:04

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.