在同一文档中使用罗马字体 (Palatino) 和无字母字体 (Arev)

在同一文档中使用罗马字体 (Palatino) 和无字母字体 (Arev)

这是一个后续问题让 mathfont 尊重周围的家庭

对于我的主要文本(\rmfamily)我想使用帕拉蒂诺以及\sffamily 阿雷夫。数学字体也应该遵守这一点。它几乎可以正常工作,但以下示例代码有两个问题:

  1. 大写希腊字母在 sans 中不起作用。我该如何解决这个问题?
  2. 我如何v从 Araev 中选择另一个,因为所选的那个与 几乎没有区别\nu。当我尝试时,\DeclareMathSymbol{v}{\mathalpha}{extraitalic}{71}它会影响所有数学字体,并且也没有粗体版本。

代码

\documentclass{book}

\usepackage[scaled=1.15]{newpxtext}
\usepackage[varg,scaled=1.15,cmintegrals]{newpxmath}
\usepackage{letltxmacro}

\renewcommand{\sfdefault}{fav}

\DeclareMathVersion{arev}

\SetSymbolFont {operators}    {arev} {OT1} {zavm}  {m} {n}
\SetSymbolFont {letters}      {arev} {OML} {zavm}  {m} {it}
\SetSymbolFont {lettersA}     {arev} {OT1} {zavm}  {m} {n} % <-- breaks some symbols
\SetSymbolFont {symbols}      {arev} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arev} {OMX} {mdbch} {m} {n}

\SetMathAlphabet {\mathrm} {arev} {OT1} {zavm} {m} {n}
\SetMathAlphabet {\mathit} {arev} {OT1} {zavm} {m} {it}
\SetMathAlphabet {\mathbf} {arev} {OT1} {zavm} {b} {n}
\SetMathAlphabet {\mathtt} {arev} {T1}  {fvm}  {m} {n}

% ander Form für v
\DeclareSymbolFont{extraitalic}{U}{zavm}{m}{it}
%\DeclareMathSymbol{v}{\mathalpha}{extraitalic}{71}% affects \rmfamily too, and doesnt have bold version

\DeclareMathVersion{arevbold}

\SetSymbolFont {operators}    {arevbold} {OT1} {zavm}  {b} {n}
\SetSymbolFont {letters}      {arevbold} {OML} {zavm}  {b} {it}
\SetSymbolFont {lettersA}     {arevbold} {OT1} {zavm}  {b} {n} % <-- breaks some symbols
\SetSymbolFont {symbols}      {arevbold} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arevbold} {OMX} {mdbch} {b} {n}

\SetMathAlphabet {\mathrm}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathit}    {arevbold} {OT1} {zavm}  {b} {it}
\SetMathAlphabet {\mathbf}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathtt}    {arevbold} {T1}  {fvm}   {b} {n}


\newif\IfInSansMode
\LetLtxMacro\oldsf\sffamily
\renewcommand*{\sffamily}{\oldsf\mathversion{arev}\InSansModetrue}
\LetLtxMacro\oldbf\bfseries
\renewcommand*{\bfseries}{\oldbf\IfInSansMode\mathversion{arevbold}\else\mathversion{bold}\fi\relax}
\LetLtxMacro\oldnorm\normalfont
\renewcommand*{\normalfont}{\oldnorm\InSansModefalse\mathversion{normal}}
\LetLtxMacro\oldrm\rmfamily
\renewcommand*{\rmfamily}{\oldrm\InSansModefalse\mathversion{normal}}

\newcommand{\TestText}{%
   $v \nu$

   $abcdefghijklmnopqrstuvwxyz$

   $ABCDEFGHIJKLMNOPQRSTUVWXYZ$

   $\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

   $\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

   $\int(1-2\cdot 10^{-5}) = \sum_i^\infty\sin x_i + a$
}

\begin{document}
\TestText

\bigskip
\bfseries
\TestText

\bigskip
\sffamily\mdseries
\TestText

\bigskip
\bfseries
\TestText

\end{document}

PS:我必须使用pdflatex...

答案1

实际上涉及很多工作,因为newpxmath要将希腊直立字母分配给lettersA符号字体并更改符号的几个位置。

\documentclass{book}
\usepackage{iftex}

\usepackage[scaled=1.15]{newpxtext}
\usepackage[varg,scaled=1.15,cmintegrals]{newpxmath}

\iftutex
  \defaultfontfeatures{Ligatures=TeX}
  \setsansfont{DejaVu Sans}
\else
  \renewcommand{\sfdefault}{fav}
\fi

\DeclareMathVersion{arev}

\SetSymbolFont {operators}    {arev} {OT1} {zavm}  {m} {n}
\SetSymbolFont {letters}      {arev} {OML} {zavm}  {m} {it}
\SetSymbolFont {lettersA}     {arev} {OT1} {zavm}  {m} {n} % <-- added
\SetSymbolFont {symbols}      {arev} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arev} {OMX} {mdbch} {m} {n}

\SetMathAlphabet {\mathrm} {arev} {OT1} {zavm} {m} {n}
\SetMathAlphabet {\mathit} {arev} {OT1} {zavm} {m} {it}
\SetMathAlphabet {\mathbf} {arev} {OT1} {zavm} {b} {n}
\SetMathAlphabet {\mathtt} {arev} {T1}  {fvm}  {m} {n}

% ander Form für v
\DeclareSymbolFont{extraitalic}{U}{zavm}{m}{it}
% affects \rmfamily too, and doesn't have bold version
%\DeclareMathSymbol{v}{\mathalpha}{extraitalic}{71}

\DeclareMathVersion{arevbold}

\SetSymbolFont {operators}    {arevbold} {OT1} {zavm}  {b} {n}
\SetSymbolFont {letters}      {arevbold} {OML} {zavm}  {b} {it}
\SetSymbolFont {lettersA}     {arevbold} {OT1} {zavm}  {b} {n} % <-- added
\SetSymbolFont {symbols}      {arevbold} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arevbold} {OMX} {mdbch} {b} {n}

\SetMathAlphabet {\mathrm}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathit}    {arevbold} {OT1} {zavm}  {b} {it}
\SetMathAlphabet {\mathbf}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathtt}    {arevbold} {T1}  {fvm}   {b} {n}


\newif\IfInSansMode
\mathchardef\normalplus="202B
\mathchardef\newpxplus="22CF
\mathchardef\normallparen=16424
\mathchardef\newpxlparen=\mathcode`(
\def\normallparencode{164608 }
\edef\newpxlparencode{\the\delcode`( }
% other similar commands
\newcommand{\choosemathversion}[1]{%
  \mathversion{#1}%
  \symbolfixes{#1}%
}
\newcommand{\symbolfixes}[1]{\csname makesymbolfixes#1\endcsname}
\newcommand{\makesymbolfixesnormal}{%
  \mathcode`+=\newpxplus
  \mathcode`(=\newpxlparen
  \delcode`(=\newpxlparencode\relax
  % other similar fixes
}
\newcommand{\makesymbolfixesarev}{%
  \mathcode`+=\normalplus
  \mathcode`(=\normallparen
  \delcode`(=\normallparencode\relax
  % other similar fixes
}
\newcommand{\makesymbolfixesarevbold}{\makesymbolfixesarev}

\AddToHook{cmd/normalfont/after}{%
  \choosemathversion{normal}\InSansModefalse
}
\AddToHook{cmd/sffamily/after}{%
  \choosemathversion{arev}\InSansModetrue
}
\AddToHook{cmd/bfseries/after}{%
  \IfInSansMode
    \choosemathversion{arevbold}%
  \else
    \choosemathversion{bold}%
  \fi
}

\begin{document}

Some text $v\nu$ with a v.

$abcdefghijklmnopqrstuvwxyz$

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

$\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

$\sin^2\alpha+\cos^2\alpha=1$

\bigskip
\bfseries

Some text $v\nu$ with a v.

$v\nu$

$abcdefghijklmnopqrstuvwxyz$

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

$\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

$\sin^2\alpha+\cos^2\alpha=1$

\bigskip
\sffamily\mdseries

Some text $v\nu$ with a v.

$v\nu$

$abcdefghijklmnopqrstuvwxyz$

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

$\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

$\sin^2\alpha+\cos^2\alpha=1$

\bigskip
\bfseries
Some text $v\nu$ with a v.

$v\nu$

$abcdefghijklmnopqrstuvwxyz$

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

$\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

$\sin^2\alpha+\cos^2\alpha=1$

\end{document}

“大量工作”是指为了来回改变输出编码必须在这些命令列表中添加内容。

如何发现要切换的代码?您将收到有关缺少字符的警告。

在此处输入图片描述

答案2

我自己找到了一个解决方案:

  1. 大写希腊文:使用原文\DeclareMathSymbol{\Gamma}{\mathalpha}{operators}{"00}source2e.pdf(第 224 页),大写希腊字母取自罗马和无字体版本的正确字体。
  2. v 与.\nu:在数学模式下激活,并将其定义为使用带有的文本字体的v斜体。v\text{\textit{v}}

在此处输入图片描述

\documentclass{book}

\usepackage[scaled=1.15]{newpxtext}
\usepackage[varg,scaled=1.15,cmintegrals]{newpxmath}
\usepackage{letltxmacro}

\renewcommand{\sfdefault}{fav}

\DeclareMathSymbol{\Gamma}{\mathalpha}{operators}{"00}
\DeclareMathSymbol{\Delta}{\mathalpha}{operators}{"01}
\DeclareMathSymbol{\Theta}{\mathalpha}{operators}{"02}
\DeclareMathSymbol{\Lambda}{\mathalpha}{operators}{"03}
\DeclareMathSymbol{\Xi}{\mathalpha}{operators}{"04}
\DeclareMathSymbol{\Pi}{\mathalpha}{operators}{"05}
\DeclareMathSymbol{\Sigma}{\mathalpha}{operators}{"06}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{operators}{"07}
\DeclareMathSymbol{\Phi}{\mathalpha}{operators}{"08}
\DeclareMathSymbol{\Psi}{\mathalpha}{operators}{"09}
\DeclareMathSymbol{\Omega}{\mathalpha}{operators}{"0A}

\DeclareMathSymbol{\intop}{\mathop}{largesymbols}{"52}
\DeclareMathSymbol{\ointop}{\mathop}{largesymbols}{"48}

\DeclareMathAlphabet {\mathsfbf} {OT1} {zavm}  {b} {n}

\DeclareMathDelimiter{(}{\mathopen} {operators}{"28}{largesymbols}{"00}
\DeclareMathDelimiter{)}{\mathclose}{operators}{"29}{largesymbols}{"01}

\DeclareMathVersion{arev}

\SetSymbolFont {operators}    {arev} {OT1} {zavm}  {m} {n}
\SetSymbolFont {letters}      {arev} {OML} {zavm}  {m} {it}
\SetSymbolFont {symbols}      {arev} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arev} {OMX} {mdbch} {m} {n}

\SetMathAlphabet {\mathrm} {arev} {OT1} {zavm} {m} {n}
\SetMathAlphabet {\mathsf} {arev} {OT1} {zavm} {m} {n}
\SetMathAlphabet {\mathit} {arev} {OT1} {zavm} {m} {it}
\SetMathAlphabet {\mathbf} {arev} {OT1} {zavm} {b} {n}
\SetMathAlphabet {\mathtt} {arev} {T1}  {fvm}  {m} {n}

\DeclareMathVersion{arevbold}

\SetSymbolFont {operators}    {arevbold} {OT1} {zavm}  {b} {n}
\SetSymbolFont {letters}      {arevbold} {OML} {zavm}  {b} {it}
\SetSymbolFont {symbols}      {arevbold} {OMS} {zavm}  {m} {n}
\SetSymbolFont {largesymbols} {arevbold} {OMX} {mdbch} {b} {n}

\SetMathAlphabet {\mathrm}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathsf}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathsfbf}  {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathit}    {arevbold} {OT1} {zavm}  {b} {it}
\SetMathAlphabet {\mathbf}    {arevbold} {OT1} {zavm}  {b} {n}
\SetMathAlphabet {\mathtt}    {arevbold} {T1}  {fvm}   {b} {n}

\newif\IfInSansMode

\let\oldsf\sffamily
\renewcommand*{\sffamily}{\oldsf\mathversion{arev}\InSansModetrue}

\let\oldbf\bfseries
\renewcommand*{\bfseries}{\oldbf\IfInSansMode\mathversion{arevbold}\else\mathversion{bold}\fi\relax}

\let\oldnorm\normalfont
\renewcommand*{\normalfont}{\oldnorm\InSansModefalse\mathversion{normal}}

\let\oldrm\rmfamily
\renewcommand*{\rmfamily}{\oldrm\InSansModefalse\mathversion{normal}}

\DeclareSymbolFont{extraitalic}{U}{zavm}{m}{it}
\SetSymbolFont{extraitalic}{arevbold} {OML} {zavm}  {b} {it}
\DeclareMathSymbol{\VarV}{\mathalpha}{extraitalic}{71}
\DeclareSymbolFont{extraitalicbold}{U}{zavm}{b}{it}
\DeclareMathSymbol{\VarVBold}{\mathalpha}{extraitalicbold}{71}
\DeclareMathSymbol{\NormalV}{\mathalpha}{letters}{`v}

\mathcode`\v="8000
{\catcode`\v=\active
\gdef v{\mathalpha{\text{\textit{\char`v}}}}}

\newcommand{\TestText}{%
   $v \nu$

%   $abcdefghijklmnopqrstuvwxyz$

%   $ABCDEFGHIJKLMNOPQRSTUVWXYZ$

%   $\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\vartheta\iota\kappa\lambda\mu\nu\xi\pi\varpi\rho\varrho\sigma\varsigma\tau\omega\psi\chi\varphi\phi\upsilon$

   $\Gamma\Delta\Theta\Lambda\Xi\Pi\Sigma\Upsilon\Phi\Psi\Omega$

%   $\int(1-2\cdot 10^{-5}) = \sum_i^\infty\sin x_i + a$
}

\begin{document}
\TestText

\bigskip
\bfseries
\TestText

\bigskip
\sffamily\mdseries
\TestText

\bigskip
\bfseries
\TestText

\end{document}

相关内容