If you run the test file
\documentclass{article}
\usepackage{lmodern}
\begin{document}
\showoutput
$n=2$
\end{document}
and look in the log file, you'll find
....\mathon
....\OML/lmm/m/it/10 n
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\OT1/lmr/m/n/10 =
....\penalty 500
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\OT1/lmr/m/n/10 2
....\mathoff
You see that actually two different fonts are used: \OML/lmm/m/it/10
and \OT1/lmr/m/n/10
. Now the problem is: what physical font is being used?
There are at least two ways for discovering it: one is to do, from the command line,
cat $(kpsewhich omllmm.fd)
that displays
% This file belongs to the Latin Modern package. The work is released
% under the GUST Font License. See the MANIFEST-Latin-Modern.txt and
% README-Latin-Modern.txt files for the details. For the most recent version of
% this license see http://www.gust.org.pl/fonts/licenses/GUST-FONT-LICENSE.txt
% or http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt
\ProvidesFile{omllmm.fd}[2009/10/30 v1.6 Font defs for Latin Modern]
\DeclareFontFamily{OML}{lmm}{\skewchar\font127 }
\DeclareFontShape{OML}{lmm}{m}{it}%
{<-5.5> lmmi5 <5.5-6.5> lmmi6
<6.5-7.5> lmmi7 <7.5-8.5> lmmi8
<8.5-9.5> lmmi9 <9.5-11> lmmi10
<11-> lmmi12
}{}
\DeclareFontShape{OML}{lmm}{b}{it}{%
<-6> lmmib5
<6-8> lmmib7
<8-> lmmib10
}{}
\DeclareFontShape{OML}{lmm}{bx}{it}%
{<->ssub*lmm/b/it}{}
\endinput
Looking for {OML}{m}{it}
and the specification for 10pt, we find lmmi10
. For the other font, we do
cat $(kpsewhich ot1lmr.fd)
and we see (showing just the relevant part)
\DeclareFontShape{OT1}{lmr}{m}{n}%
{<-5.5> rm-lmr5 <5.5-6.5> rm-lmr6
<6.5-7.5> rm-lmr7 <7.5-8.5> rm-lmr8
<8.5-9.5> rm-lmr9 <9.5-11> rm-lmr10
<11-15> rm-lmr12
<15-> rm-lmr17
}{}
so the font is rm-lmr10
.
Second way: modify the test file to be
\documentclass{article}
\usepackage{lmodern}
\begin{document}
\showoutput
$n=2$
\texttt{\fontname\csname OML/lmm/m/it/10\endcsname}
\texttt{\fontname\csname OT1/lmr/m/n/10\endcsname}
\end{document}
and the output will be
However, you may want to use the OpenType fonts. Then modify the test file again to be
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\showoutput
$n=2$
\end{document}
The log file, after running LuaLaTeX on the file, will show
....\EU2/latinmodern-math.otf(0)/m/n/10 𝑛
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\EU2/latinmodern-math.otf(0)/m/n/10 =
....\penalty 500
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\EU2/latinmodern-math.otf(0)/m/n/10 2
....\mathoff
So modify it again essentially as before:
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\showoutput
$n=2$
\texttt{\fontname\csname EU2/latinmodern-math.otf(0)/m/n/10\endcsname}
\end{document}
and the output will be
Now you know what font you should load in the external program.
Indeed, if I copy from the log file the 𝑛 glyph and paste in a word processing application I get
slanted
, notitalic
.