Объявление определенного математического символа в шрифте TTF (LuaLaTeX)

Объявление определенного математического символа в шрифте TTF (LuaLaTeX)

Я пытаюсь обойти классическую проблему в LaTeX для тех, кто имеет дело с электромагнетизмом:определить нотацию скрипта Гриффитса. На этот раз я хочу сделать это, используя настоящий шрифт Кауфмана, который он использует в своей книге, и мне уже удалось получить файлы. Хотя в LuaLaTeX легко использовать шрифты "свободно", я хочу определить математический символ, который использует его, чтобы код хорошо работал с другими используемыми мной пакетами, такими как команды bold vector, определенныеphysics.

После прочтенияэтот ответв посте, посвященном общей проблеме script-r, я пытался реализовать нотацию script-r с помощью команды \DeclareMathSymbol, но не могу понять, как использовать в ней шрифт Кауфмана.

Короче говоря: у меня есть два .ttfфайла шрифтов, Kaufmann-Regular.ttfи Kaufmann-Bold.ttf. Как я могу использовать их для определения математического символа \rcursс помощью шрифта Kaufmann, чтобы команды типа \mathbf{\rcurs}возвращали его жирную версию?

решение1

Математические алфавиты и операторы образуют набор, поэтому для их комбинирования обычно требуются низкоуровневые корректировки различного рода.

Тем не менее, существуют различные способы и методы импорта символа.


(1)

Самый простой способ — включить глифы в виде изображений\PDF-файлов и изменять их размер и т. д. по мере необходимости, как это делает Гриффитс:

Код:

\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}

изображение

Посмотреть zip-файл Griffithshttp://academic.reed.edu/physics/faculty/griffiths/script_r.zip, с помощьюСимвол Script-r


(2)

Следующий самый простой способ — использовать одну из \math...функций (здесь, \mathord):Определение математического символа переменного размера в XeTeX с помощью \Umathchardefс помощьюLuaTeX: использовать один символ из другого шрифта в математическом режиме

Вот их список:

список математика

(textdoc source2e)

гм2

МВЭ

\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}

(2а)

Для правильной настройки ударения потребуется кернинг и т. д. Здесь другой, не математический шрифт позволяет избежать этой проблемы:

гм3

МВЭ

\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)

Далее выполняется сопоставление с использованием опции шрифта unicode-mathпакета range=.

Сопоставление с математическим шрифтом Unicode:

гм

МВЭ

\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использует устаревшие методы шрифтов. Шрифты ttf\otf можно использовать, назначив им псевдоним NFSS через fontspecпакет (например, xelatex или lualatex в качестве компилятора), а затем выполнив несколько шагов в соответствии со связанным вопросом.

Вариант такой NFSSFamily=.

флоральный

В примере используется QTFloralineшрифт (в дистрибутиве tex)L, он имеет обычное и жирное начертание. Вместо этого замените ваши файлы kaufmann.

МВЭ

\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)

Для одного или двух символов этот \mathord{}метод проще и не требует использования целого математического алфавита.

Как оказалось, unicode-mathопределяет два макроса, \mbfscrrи \mscrr. Их можно просто переопределить ( renewcommand) через \mathord, и всё.

Код поэтапно демонстрирует, что именно нужно изменить, иллюстрируя каждый результат и достигая последнего шага с использованием QTChanceryTypeшрифта:

макросы

МВЭ

\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}

Приложение

Во избежание двусмысленности, текстовый режим и математический режим — это совершенно разные вселенные с точки зрения шрифтов.

курсив x

Где курсив x (

Связанный контент