2

I like to use \usepackage{mlmodern} but I noticed it changes ' in listings. Is there to tell it not to do this? I use lualatex.

Here is MWE

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mlmodern}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[language=Mathematica,basicstyle=\ttfamily\small]
DSolve[y'[x]==(x+y[x])^(1/2),y[x],x]
\end{lstlisting}
\end{document}

The output PDF shows this

enter image description here

Compiling without mlmodern gives

enter image description here

The problem with the first version is that now one can't copy and paste the code as is, since it is no longer valid. It should remain ' and not backquote

TL 2022 on Linux.

Update:

Same issue happens with pdflatex. But with pdflatex with and without mlmodern it changes to backquote.

Nasser
  • 20,220
  • There is no OpenType version of MLModern, so using LuaLaTeX is not really a choice. – egreg Jul 15 '22 at 12:50
  • @egreg I've been using it with lualatex for a year now, and had no problem at all. Except for this minor issue with lisiting and quote character. In addition, same problem happens with pdflatex. (but noticed with pdflatex it is always backquote which is even more strange). – Nasser Jul 15 '22 at 12:54

1 Answers1

2

Reading the manual can help.

enter image description here

Actually the reference to textcomp is outdated.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{mlmodern}
\usepackage{listings}

\lstset{upquote}

\begin{document}

\begin{lstlisting}[language=Mathematica,basicstyle=\ttfamily\small] DSolve[y'[x]==(x+y[x])^(1/2),y[x],x] \end{lstlisting}

\end{document}

enter image description here

I can't recommend using LuaLaTeX as is with fonts not in OpenType format. Also, terminology is wrong: there is no back quote in your output, but rather a closing quote .

By the way, this is the output I get without mlmodern and not setting upquote, using LuaLaTeX:

enter image description here

So there's something you didn't tell.

egreg
  • 1,121,712