Respuestas a la preguntaVolviendo a Computer Modern dentro de XeLaTeXproporciona una forma de volver a la fuente predeterminada en XeLaTex. Sin embargo, la solución no funciona si la uso \mathrm
en una fórmula:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
%\newfontfamily\lmodern{Latin Modern Roman} % If font exists on your system
% Optical sizes need to be set up manually using the [SizeFeatures] option
% or select the font using the regular font selection methods
\newcommand{\lmr}{\fontfamily{lmr}\selectfont} % Latin Modern Roman
\newcommand{\lmss}{\fontfamily{lmss}\selectfont} % Latin Modern Sans
\newcommand{\lmtt}{\fontfamily{lmtt}\selectfont} % Latin Modern Mono
\begin{document}
\[\mathrm{e}^{\mathrm{i}\pi}+1=0\]
{\lmr\[\mathrm{e}^{\mathrm{i}\pi}+1=0\]}
\end{document}
Puede ver que las letras e y i todavía no están en la fuente predeterminada. El uso de otras fuentes hará que las fórmulas se vean aún peor, como Consolas.
¿Qué debo hacer para solucionarlo?
Respuesta1
Si desea mantener Latin Modern como fuente matemática y de texto predeterminada, no ejecute \setmainfont
instrucciones. Por el contrario, si desea cambiar la fuente del texto principal a Linux Libertine O, probablemente debería cargar el unicode-math
paquete y ejecutar \setmathfont{Libertinus Math}
. Por otro lado, si desea Libertine para material en modo texto pero Latin Modern para material en modo matemático, es posible que desee reemplazarlo \setmathfont{Libertinus Math}
con \setmathfont{Latin Modern Math}[Scale=MatchLowercase]
.
%% execute this test file under XeLaTeX or LuaLaTeX
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Linux Libertine O}
\begin{document}
\setmathfont{Libertinus Math}
$\mathrm{e}^{\mathrm{i}\pi}+1=0$
\setmathfont{Latin Modern Math}[Scale=MatchLowercase] % or Scale=MatchUppercase
$\mathrm{e}^{\mathrm{i}\pi}+1=0$
\end{document}
Apéndice: Como señala @cabohah en un comentario, \setmainfont{Linux Libertine O}
es posible que no funcione con algunas combinaciones de distribución/sistema operativo TeX. Si eso es un problema para usted, puede ser preferible cargar los paquetes libertine
, libertinus
o libertinus-otf
en lugar de ejecutar las instrucciones \setmainfont
y \setmathfont
.