Consider this simple example:



Running with lualatex works fine, but pdflatex gives an error:

! Missing $ inserted.
<inserted text> 
l.5 $\texttt{\lambda}

I assume this is rooted in the different font treatment of the two tools, but shouldn't pdflatex then either report "I cannot show this symbol"? Why this confusion math mode error?

  • Using \text… in math mode seems wrong, anyway. – clemens Apr 14 '16 at 12:58

The outer $ are mostly irrelevant, because \texttt starts text mode, so you get exactly the same with \texttt{\lambda}: a standard math mode lambda in LuaLaTeX (provided math fonts have been initialized, which happens in your example exactly because math mode had started) and an error in legacy TeX engines and XeLaTeX.

The \lambda macro is a \mathchardef token (as it always has) so there is no 'active' opt-in here in LaTeX, it's just inherited from the engine. The behaviour of \mathchar in LuaTeX has been altered to allow it outside outside of math mode:

Allowed math commands in non-math modes The commands \mathchar, and \Umathchar and control sequences that are the result of \mathchardef or \Umathchardef are also acceptable in the horizontal and vertical modes. In those cases, the \textfont from the requested math family is used.

(LuaTeX manual, section 'Allowed math commands in non-math modes', page 79 in version for LuaTeX 0.95, page 153 in version for LuaTeX 0.80).

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.