.png)
Estoy intentando solucionar un problema clásico en LaTeX para cualquiera que se ocupe del electromagnetismo:definir la notación script-r de Griffiths. Esta vez, quiero hacerlo usando la fuente Kaufmann real que usa en su libro, y ya logré conseguir los archivos. Si bien en LuaLaTeX es fácil usar las fuentes "libremente", quiero definir un símbolo matemático que lo use para que el código funcione bien con otros paquetes que uso, como los comandos vectoriales en negrita definidos porphysics
.
Despues de leeresta respuestaEn la publicación sobre el problema genérico de script-r, estaba intentando implementar la notación script-r mediante el \DeclareMathSymbol
comando, pero no puedo entender cómo usar la fuente Kaufmann en él.
En resumen: tengo dos .ttf
archivos de fuentes Kaufmann-Regular.ttf
y Kaufmann-Bold.ttf
. ¿Cómo puedo usarlos para definir un símbolo matemático \rcurs
usando la fuente Kaufmann de modo que comandos como \mathbf{\rcurs}
devuelvan su versión en negrita?
Respuesta1
Los alfabetos matemáticos y los operadores forman un conjunto, por lo que mezclar y combinar generalmente requerirá ajustes de bajo nivel de diferentes tipos.
Dicho esto, existen varias formas y métodos para importar un símbolo.
(1)
La forma más sencilla es incluir los glifos como imágenes\PDF y cambiar el tamaño, etc. cuando sea necesario, como lo hace Griffiths:
Código:
\documentclass{report}
\usepackage{graphicx}
\def\rcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{ScriptR}}$}}}
\def\brcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{BoldR}}$}}}
\def\hrcurs{{\mbox{$\hat \brcurs$}}}
\begin{document}
Here's a sample:
$\resizebox{.16in}{.08in}{\includegraphics{BoldR}}$
Can I put it into a line of type? $\resizebox{.21in}{.11in}{\includegraphics{BoldR}}$
How about using the macro: \brcurs.
How about using the macro: \rcurs?
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
{\bf E} = {1\over 4\pi\epsilon_0}\int {\rho\over \rcurs^2}{\hrcurs}\,d\tau.
\end{equation}
\end{document}
Ver el archivo zip de Griffithshttp://academic.reed.edu/physics/faculty/griffiths/script_r.zip, a través deSímbolo script-r
(2)
La siguiente forma más sencilla es utilizar una de las \math...
funciones (aquí \mathord
):Definiendo un símbolo matemático de tamaños variables en XeTeX con \Umathchardefa través deLuaTeX: use un solo símbolo de otra fuente en modo matemático
Aquí hay una lista de ellos:
(textdoc fuente2e)
MWE
\documentclass{report}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana-Math}
\newfontfamily{\miama}{Miama}[Colour=red,
Scale=1.3,
Path=C:/Users/.../tl/texlive/2020/texmf-dist/fonts/opentype/public/miama/,
Extension=.otf,
UprightFont=*,
]
\DeclareRobustCommand\mysym{%
\mathord{\text{\normalfont\miama r}}%
}
%\def\rcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{ScriptR}}$}}}
%\def\brcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{BoldR}}$}}}
%\def\hrcurs{{\mbox{$\hat \brcurs$}}}
\def\hrcurs{{\mbox{$\hat\mbfscrr$}}}
\begin{document}
\fbox{Asana-Math: $\mbfscrr, \mscrr $}
Here's a sample:
$\mbfscrr$
Can I put it into a line of type? $\mbfscrr$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mscrr^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\renewcommand\mbfscrr{{\mysym}}
\def\hrcurs{{\mbox{$\hat\mbfscrr$}}}
\bigskip
\fbox{Miama: $\mysym$}
Here's a sample:
$\mysym$
Can I put it into a line of type? $\mysym$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mscrr^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\end{document}
(2a)
Para corregir los ajustes de acento será necesario el interletraje, etc. Aquí, una fuente diferente no matemática evita ese problema:
MWE
\documentclass{report}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana-Math}
\newfontfamily{\gfs}{GFSBodoni}[Colour=red,
Scale=1.3,
Path=C:/Users/.../tl/texlive/2020/texmf-dist/fonts/opentype/public/gfsbodoni/,
Extension=.otf,
UprightFont=*,
ItalicFont=GFSBodoniIt,
BoldFont=GFSBodoniBold,
BoldItalicFont=GFSBodoniBoldIt,
]
\DeclareRobustCommand\mysymbi{%
\mathord{\text{\normalfont\gfs\bfseries\itshape r}}%
}
\DeclareRobustCommand\mysym{%
\mathord{\text{\normalfont\gfs\itshape r}}%
}
\def\hrcurs{{\mbox{$\hat\mbfscrr$}}}
\begin{document}
\fbox{Asana-Math: $\mbfscrr, \mscrr $}
Here's a sample:
$\mbfscrr$
Can I put it into a line of type? $\mbfscrr$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mscrr^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\renewcommand\mbfscrr{{\mysymbi}}
\def\hrcurs{{\mbox{$\hat\mbfscrr$}}}
\bigskip
\fbox{GFS Bodoni: $\mysymbi, \mysym$}
Here's a sample:
$\mysym$
Can I put it into a line of type? $\mysym$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mysym^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\end{document}
(3)
A continuación, mapeamos usando la opción de fuente unicode-math
del paquete range=
.
Mapeo desde una fuente matemática Unicode:
MWE
\documentclass{report}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana-Math}
\def\hrcurs{{\mbox{$\hat\mbfscrr$}}}
\begin{document}
\fbox{Asana-Math: $\mbfscrr,\mscrr$}
Here's a sample:
$\mbfscrr$
Can I put it into a line of type? $\mbfscrr$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mscrr^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\setmathfont{TexGyreSchola-Math}[range={\mbfscrr,\mscrr},Colour=red]
\bigskip
\fbox{TexGyreSchola-Math: $\mbfscrr,\mscrr$}
Here's a sample:
$\mbfscrr$
Can I put it into a line of type? $\mbfscrr$
How about using the macro: \hrcurs?
What if it's in an equation?
\begin{equation}
\symbf{E} = {1\over 4\mitpi\mitepsilon_0}\int {\mitrho\over \mscrr^2}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\end{document}
(4)
\DeclareMathSymbol
utiliza técnicas de fuentes heredadas. Las fuentes ttf\otf se pueden usar asignándoles un alias NFSS a través fontspec
del paquete (es decir, xelatex o lualatex como compilador) y luego siguiendo varios pasos según la pregunta vinculada.
La opción es NFSSFamily=
.
El ejemplo usa QTFloraline
fuente (en la distribución tex) L tiene una cara normal y una cara en negrita. En su lugar, reemplace sus archivos Kaufmann.
MWE
\documentclass{article}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana-Math}
\newfontface\ffontc{QTFloraline}[
Extension=.otf,
UprightFont=*,
BoldFont=*-Bold,
NFSSFamily=floraline,
]
\usepackage{bm}
\DeclareFontFamily{U}{floraline}{}
\DeclareFontShape{U}{floraline}{m}{n}{<-> QTFloraline}{}
\DeclareFontShape{U}{floraline}{b}{n}{<-> QTFloraline-Bold}{}
\DeclareSymbolFont{myfloraline}{U}{floraline}{m}{n}
\SetSymbolFont{myfloraline}{bold}{U}{floraline}{b}{n}
\DeclareMathSymbol{\rcurs}{\mathalpha}{myfloraline}{`\r}
\DeclareBoldMathCommand{\brcurs}{\rcurs}
\newcommand*\hrcurs{\hat{\brcurs}}
\begin{document}
\[
\mathbf{E}(\mathbf{r}) = \frac{1}{4 \pi \epsilon_0} \int\limits_{\mathcal{V}} \frac{\rho(\mathbf{r}')}{\rcurs^2} \hrcurs d \tau'
\]
Using \texttt{unicode-math} macros:
\[
\symbfup{E}(\symbfup{r}) = \frac{1}{4 \mitpi \mitepsilon_0} \int\limits_{\symcal{V}} \frac{\mitrho(\symbfup{r}')}{\rcurs^2} \hrcurs d \mittau'
\]
\end{document}
(5)
Para uno o dos símbolos, el \mathord{}
método es más sencillo y tampoco utiliza todo un alfabeto matemático.
Resulta que unicode-math
define dos macros \mbfscrr
y \mscrr
. Estos pueden simplemente redefinirse ( renewcommand
) mediante \mathord
, y eso es todo.
El código recorre las etapas de qué cambiar, ilustrando cada resultado y llegando al paso final usando QTChanceryType
la fuente:
MWE
\documentclass{report}
\usepackage{xcolor}
\usepackage{unicode-math}
\setmathfont{Asana-Math}
\newfontface\bodb{BOD_BLAR.TTF}[Colour=red]
\newfontface\ffontbreg{QTChanceryType.otf}
\newfontface\ffontbbold{QTChanceryType-Bold.otf}
\DeclareRobustCommand\xmbfscrr{%
\mathord{\text{\normalfont\bodb A}}%
}
\DeclareRobustCommand\myscrr{%
\mathord{\text{\normalfont\ffontbreg r}}%
}
\DeclareRobustCommand\mybfscrr{%
\mathord{\text{\normalfont\ffontbbold r}}%
}
\begin{document}
%======================: 0: base
\fbox{Asana-Math: $\mbfscrr,\mscrr$}
\begin{equation}
\symbfup{E} = {\frac{1}{4\mitpi\mitepsilon_0}}\int {\frac{\mitrho}{\mscrr^2}}{\hat\mbfscrr}\,d\mittau.
\end{equation}
%======================: 1: A
\renewcommand{\mbfscrr}{A}
\bigskip
\begin{equation}
\symbfup{E} = {\frac{1}{4\mitpi\mitepsilon_0}}\int {\frac{\mitrho}{\mscrr^2}}{\hat\mbfscrr}\,d\mittau.
\end{equation}
%======================: 2: A from another font
\renewcommand{\mbfscrr}{{\xmbfscrr}}
\bigskip
\begin{equation}
\symbfup{E} = {\frac{1}{4\mitpi\mitepsilon_0}}\int {\frac{\mitrho}{\mscrr^2}}{\hat\mbfscrr}\,d\mittau.
\end{equation}
%======================: 3: r and bold r, from another font
\renewcommand{\mbfscrr}{{\mybfscrr}}
\renewcommand{\mscrr}{{\myscrr}}
\bigskip
\begin{equation}
\symbfup{E} = {\frac{1}{4\mitpi\mitepsilon_0}}\int {\frac{\mitrho}{\mscrr^2}}{\hat\mbfscrr}\,d\mittau.
\end{equation}
\end{document}
Apéndice
Para evitar ambigüedades, el modo texto y el modo matemático son universos completamente diferentes, en términos de fuentes.
¿De dónde viene la cursiva x (