3
\documentclass{article}
\usepackage{unicode-math}
\usepackage{listings}
\usepackage{fancyvrb}

\begin{document}
\lstset{fancyvrb}
\begin{Verbatim}[commandchars=\\\{\}]
\pm 
\end{Verbatim}
\end{document}

This is the minimal code. And I get the error "Improper alphabetic constant".

PS: I need \lstset{fancyvrb}.

1
  • A warm welcome to TeX.SE! – A Feldman Apr 4 '16 at 4:54
5

\pm is internally defined as "the character ±". In the listings code \pm is used in an \lccode assigment but its value is much too large. You can avoid the problem by converting \pm to a macro. This is handled differently by listings. E.g.

\documentclass{article}
\usepackage{unicode-math}
\usepackage{listings}
\usepackage{fancyvrb}

\AtBeginDocument{%
 \let\ORIpm\pm
 \renewcommand\pm{\ORIpm}}

\begin{document}


\lstset{fancyvrb}
\begin{Verbatim}[commandchars=\\\{\}]
\pm
\end{Verbatim}

\end{document}

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.