
Estoy intentando componer un documento en Linux Libertine y también quiero usar la fuente para caracteres alfanuméricos en modo matemático. Estoy usando unicode-math
, no mathspec
, porque necesito especificar alfabetos como mathup
explícitamente para compatibilidad con paquetes como hepnames
. No encontré una manera de hacer eso con mathspec
. El motor que uso es XeLaTeX. Inicialmente especifico TeX Gyre Pagella Math como una fuente matemática completa para símbolos, etc. Quiero que las declaraciones posteriores sobrescriban la fuente para caracteres de texto como Libertine.
Encuentro varios problemas, ilustrados por el MWE a continuación:
- El
\boldmath
interruptor no hace nada. - Los números no se representan correctamente en negrita y cursiva, solo letras.
\mathbf
(la última "A = 1" en el MWE) se representa en Pagella, no en Libertine en absoluto.
Ya intenté agregar /{latin,Latin,num}
a las range
declaraciones, sin éxito. ¿Que me estoy perdiendo aqui?
\documentclass{minimal}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont[%
Ligatures=TeX,
BoldFont=LinLibertine_RB.otf,
ItalicFont=LinLibertine_RI.otf,
BoldItalicFont=LinLibertine_RBI.otf]
{LinLibertine_R.otf}
\setmathfont{texgyrepagella-math.otf}
\setmathfont[range=\mathup]{LinLibertine_R.otf}
\setmathfont[range=\mathbf]{LinLibertine_RB.otf}
\setmathfont[range=\mathit]{LinLibertine_RI.otf}
\setmathfont[range=\mathbfit]{LinLibertine_RBI.otf}
\begin{document}
\begin{tabular}{lll}
Text & A = 1 & \textit{B = 2}\\
Textbf & \textbf{A = 1} & \textbf{\textit{B = 2}}\\
Math & $A = 1$ & $\mathit{B = 2}$\\
Boldmath & {\boldmath $A = 1$} & {\boldmath $\mathit{B = 2}$}\\
Mathbf & $\mathbf{A = 1}$ & $\mathbfit{B = 2}$\\
\end{tabular}
\end{document}
Sin cambios de fuente, todo se ve bien:
\documentclass{minimal}
\begin{document}
\begin{tabular}{lll}
Text & A = 1 & \textit{B = 2}\\
Textbf & \textbf{A = 1} & \textbf{\textit{B = 2}}\\
Math & $A = 1$ & $\mathit{B = 2}$\\
Boldmath & {\boldmath $A = 1$} & {\boldmath $\mathit{B = 2}$}\\
\end{tabular}
\end{document}
Respuesta1
Encontré una solución que funciona para mí. Empecé a jugar con él version=bold
, como sugirió David, pero eso siguió resultandotodoMi texto en modo matemático está en negrita. Al final cambié de nombres de archivos a nombres de fuentes del sistema. (Quería evitar eso inicialmente, ya que estoy trabajando en el mismo documento desde varias máquinas diferentes). Con los nombres de fuentes del sistema, \boldmath
funcionó de forma inmediata y automática. También descubrí que \mathbfup
se debe especificar en lugar de \mathbf
.
Otro problema con el uso de nombres de fuentes del sistema es que, por alguna razón, el estilo Libertine semi-negrita se carga de forma predeterminada en negrita. Ésta es la razón de la BoldFont
especificación en el MWE a continuación.
La solución no es perfecta. Puedes ver que todos los números en el modo matemático se muestran en posición vertical, incluso en formato \mathit
. Además, el número \mathbfit
no está en negrita. Sin embargo, todas las fuentes son correctas y es lo suficientemente buena para mis propósitos.
\documentclass{minimal}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont[
BoldFont=Linux Libertine Bold,
BoldItalicFont=Linux Libertine Bold Italic]
{Linux Libertine}
\setmathfont{TeX Gyre Pagella Math}
\setmathfont[range=\mathup,
BoldFont=Linux Libertine Bold,
BoldItalicFont=Linux Libertine Bold Italic]
{Linux Libertine}
\setmathfont[range=\mathit,
BoldFont=Linux Libertine Bold Italic]
{Linux Libertine Italic}
\setmathfont[range=\mathbfup]{Linux Libertine Bold}
\setmathfont[range=\mathbfit]{Linux Libertine Bold Italic}
\begin{document}
\begin{tabular}{lll}
~ &\ Regular &\ Italic\\
Text &\ A = 1 &\ \textit{A = 1}\\
Textbf &\ \textbf{A = 1} &\ \textbf{\textit{A = 1}}\\
Math &\ $A = 1$ &\ $\mathit{A = 1}$\\
Boldmath &\ {\boldmath $A = 1$} &\ {\boldmath $\mathit{A = 1}$}\\
Mathbf &\ $\mathbf{A = 1}$ &\ $\mathbfit{A = 1}$\\
\end{tabular}
\end{document}
Respuesta2
tg85 anotódos problemas con la respuesta que proporcionó a su propia pregunta:
La solución no es perfecta. Puedes ver que todos los números en el modo matemático se muestran en posición vertical, incluso en formato
\mathit
. Además, el número\mathbfit
no está en negrita. Sin embargo, todas las fuentes son correctas y es lo suficientemente buena para mis propósitos.
ElUnicode-matemáticasmanual(Figura 7) afirma que la forma vertical en realidad se elige a propósito para los números porque "siempre deben tomarse de la fuente vertical, incluso en el estilo en cursiva". De acuerdo con esta afirmación, parece que Unicode no define espacios para dígitos en cursiva, aunque sí define espacios para dígitos en negrita, dígitos sans-serif, etc.https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode#Mathematical_Alphanumeric_Symbols_block.
Puedo entender, sin embargo, que todavía se desee que la composición tipográfica producida porUnicode-matemáticaspara ser coherente con la composición tipográfica original basada en LaTeX, donde \mathit{1}
se produce un dígito en cursiva. Por lo tanto, inspirado porcódigo de tg85, se me ocurrió una solución que soluciona estos dos problemas (también funciona con LuaLaTeX):
% !TEX program = xelatex
\documentclass{minimal}
\usepackage{ifthen}
\usepackage[svgnames]{xcolor}
\usepackage[
mathit = sym, mathup = sym, mathbf = sym,
math-style = ISO, bold-style = ISO
]{unicode-math}
\setmainfont{LinLibertine_R.otf}[
ItalicFont = LinLibertine_RI.otf,
BoldFont = LinLibertine_RB.otf,
BoldItalicFont = LinLibertine_RBI.otf
]
\setmonofont{FiraMono-Medium.otf}[
Scale = 0.81,
Color = DarkBlue
]
\setmathfont{XITSMath-Regular.otf}[
BoldFont = XITSMath-Bold.otf
]
\setmathfont{XITSMath-Regular.otf}[
version = mathitVersion
]
\setmathfont{XITSMath-Regular.otf}[
version = mathbfitVersion
]
\setmathfont{XITSMath-Bold.otf}[
version = boldmathVersion
]
\setmathfont{LinLibertine_R.otf}[
range = up/{num, latin, Latin, greek, Greek},
BoldFont = LinLibertine_RB.otf
]
\setmathfont{LinLibertine_RI.otf}[
range = it/{num, latin, Latin, greek, Greek},
BoldFont = LinLibertine_RBI.otf,
NFSSFamily = mathitalic
]
\setmathfont{LinLibertine_RBI.otf}[
range = bfit/{latin, Latin, greek, Greek},
NFSSFamily = mathbolditalic
]
\setmathfont{LinLibertine_RB.otf}[
range = bfup/{num, latin, Latin, greek, Greek}
]
\newif \ifBoldMath \BoldMathfalse
\let \mathversionorig \mathversion
\renewcommand{\mathversion}[1]{%
\ifthenelse{\equal{#1}{bold}}{%
\BoldMathtrue%
}{%
\BoldMathfalse%
}%
\mathversionorig{#1}%
}
\AtBeginDocument{%
\let \mathitorig \mathit%
\renewcommand{\mathit}[1]{%
\ifBoldMath%
\textbf{%
\SetSymbolFont{__um_fam1}{boldmathVersion}{TU}{mathbolditalic}{b}{it}%
\SetSymbolFont{__um_fam2}{boldmathVersion}{TU}{mathbolditalic}{b}{it}%
\mathversion{boldmathVersion}%
\(\mathitorig{#1}\)%
}
\else%
\textit{%
\SetSymbolFont{__um_fam1}{mathitVersion}{TU}{mathitalic}{m}{it}%
\mathversion{mathitVersion}%
\(\mathitorig{#1}\)%
}%
\fi%
}%
\let \mathbfitorig \mathbfit%
\renewcommand{\mathbfit}[1]{{%
\textbf{%
\SetSymbolFont{__um_fam1}{mathbfitVersion}{TU}{mathbolditalic}{b}{it}%
\mathversion{mathbfitVersion}%
\(\mathbfitorig{#1}\)%
}%
}}%
}
\newcommand{\testUnicodeMath}{%
\bigskip
\begin{tabular}{l @{\quad}l @{\quad} l @{\quad} l @{\quad} l}
Row
& Math version/alphabet
& Regular
& Upright
& Italic \\[\medskipamount]
1
& Text
& A = 1a
& \textup{B = 2b}
& \textit{C = 3c} \\
2 &
\texttt{\textbackslash textbf}
& \textbf{A = 1a}
& \textbf{\textup{B = 2b}}
& \textbf{\textit{C = 3c}} \\
3
& \texttt{\textbackslash mathversion\{normal\}} (default)
& $A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}$
& $\mathup{B = 2b + \beta \times \Gamma}$
& $\mathit{C = 3c + \beta \times \Gamma}$ \\
4
& \texttt{\textbackslash mathversion\{bold\}}/\texttt{\textbackslash boldmath}
& \boldmath $A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}$
& \boldmath $\mathup{B = 2b + \beta \times \Gamma}$
& \boldmath $\mathit{C = 3c + \beta \times \Gamma}$ \\
5
& \texttt{\textbackslash mathbf}/\texttt{\textbackslash mathbfup}/\texttt{\textbackslash mathbfit}
& $\mathbf{A = 1a + \beta \times \Gamma \int_{-\infty}^{\infty} \frac{\mathup{d}x}{2}}$
& $\mathbfup{B = 2b + \beta \times \Gamma}$
& $\mathbfit{C = 3c + \beta \times \Gamma}$ \\
\end{tabular}%
\bigskip
\bigskip
}
\begin{document}
\testUnicodeMath
\textit{Check that everything works properly by invoking it a~second time:}
\testUnicodeMath
\textit{Check that everything works properly by invoking it a~third time:}
\testUnicodeMath
\end{document}
Esto produce el siguiente resultado: tenga en cuenta que el "3" en la fila 3 de la tabla ahora está en cursiva y en negrita y cursiva en las filas 4 y 5 de la tabla:
Tenga en cuenta también el contraste entre \mathversion{bold}
/ \boldmath
y \mathbf
/ \mathbfup
/ \mathbfit
: el primero también pone en negrita todos los operadores, integrales, etc., mientras que el segundo sólo afecta a letras y dígitos.
Respuesta3
El uso del paquete amsbsy y \pmb parece generar negrita.
\documentclass{minimal}
\usepackage{fontspec}
\usepackage{unicode-math}
\usepackage{amsbsy}
\setmainfont[%
Ligatures=TeX,
BoldFont=LinLibertine_RB.otf,
ItalicFont=LinLibertine_RI.otf,
BoldItalicFont=LinLibertine_RBI.otf]
{LinLibertine_R.otf}
\setmathfont{texgyrepagella-math.otf}
\setmathfont[range=\mathup]{LinLibertine_R.otf}
\setmathfont[range=\mathbf]{LinLibertine_RB.otf}
\setmathfont[range=\mathit]{LinLibertine_RI.otf}
\setmathfont[range=\mathbfit]{LinLibertine_RBI.otf}
\begin{document}
\begin{tabular}{lll}
Text & A = 1 & \textit{B = 2}\\
Textbf & \textbf{A = 1} & \textbf{\textit{B = 2}}\\
Math & $A = 1$ & $\mathit{B = 2}$\\
Boldmath & { $\pmb{A = 1}$} & {$\pmb{\mathit{B = 2}}$}\\
Mathbf & $\mathbf{A = 1}$ & $\mathbfit{B = 2}$\\
\end{tabular}
\end{document}
Respuesta4
Con xelatex
olualatex
\documentclass{standalone}
\usepackage{hepparticles}
\usepackage{hepnames}
\usepackage[math-style=ISO]{unicode-math}
\usepackage{libertinus}
\usepackage{array}
\begin{document}
\tabcolsep=10pt
\begin{tabular}{>{\ttfamily\textbackslash}lll}
normalfont & Regular &\itshape Italic\\
textnormal & A = 1 & \textit{A = 1}\\
textbf & \textbf{A = 1} & \textbf{\textit{A = 1}}\\
mathup & $\mathup{A} = 1$ & $A = 1$\\
symbf & $\symbfup{A = 1}$ & $\symbfit{A = 1}$\\
mathbf & $\mathbf{A = 1}$ & $\mathbfit{A = 1}$\\
\end{tabular}
\end{document}