3

I am trying to move from XeLaTeX to LuaLaTeX. I have some listings with special delimeters (an underscore). The following MWE compiles perfectly under XeLaTex, but gives the following error under LuaLaTeX:

Error Message:

./plots.tex:36: Missing $ inserted.
<inserted text> 
$
l.36 TABLE1(_ID1_
               ,DATA1)
? 
Process aborted

MWE:

%!TEX TS-program = lualatex
%!TEX encoding = UTF-8 Unicode
\documentclass[11pt, a4paper]{article}
\usepackage[dvipsnames,svgnames,x11names,hyperref]{xcolor}
\usepackage{unicode-math}
\usepackage{listings}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\lstdefinestyle{mystyle}{
    language=SQL,
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\small\ttfamily\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\small\ttfamily,
    breakatwhitespace=false,         
    breaklines=true,                 
    captionpos=t,                    
    keepspaces=true,                 
    numbers=left,                    
    numbersep=5pt,                  
    showspaces=false,                
    showstringspaces=false,
    showtabs=false,                  
    tabsize=4,
    moredelim=[is][\underbar]{_}{_},
    moredelim=**[is][\bfseries]{@}{@},
    escapeinside={(*@}{@*)}
}
\begin{document}
\lstset{style=mystyle}
\begin{lstlisting}[caption=Database Tables, label={lst:tables}]
TABLE1(_ID1_,DATA1)
TABLE1(_ID2_,DATA2)
TABLE3(_ID3_,DATA3)
\end{lstlisting}
\end{document}

Additional Info:

  1. I'm using MacTeX 2014.
  2. I tried to use the underscore package, but that didn't help.
  3. I tried to change the delimeter, and that didn't help neither.
  • I get the same errors in XeLaTeX and in LuaLaTeX. – egreg Oct 1 '14 at 6:38
4

The problem is the \underbar command in your moredelim setting: With unicode-math it is a math command. You could use e.g. the ulem package and \uline instead:

\usepackage{ulem}
...

`moredelim=[is][\uline]{_}{_},`
|improve this answer|||||
  • 1
    Why not \underline without any package? – egreg Oct 1 '14 at 8:03
  • 1
    @egreg: Why easy when you can do it in a complicated way? ;-). Actually I tried \underlinebut got an error due to an \underbar still lurking around and so thought that \underline has the same problem. – Ulrike Fischer Oct 1 '14 at 8:23

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.