我需要使用不同字体的数学符号,超过 16 个。调整我的设置以便能够使用更多数学字体的最简单方法是什么?
我正在寻找以下任一项:
- 让我绕过限制的黑客
- 另一个可能与我目前使用的设置最兼容的设置是
pdflatex
我知道有 LuaTeX 和 XeTeX 等系统/引擎(两者都允许使用超过 16 种数学字体),但我真的在寻找尽可能保守的 LaTeX 扩展。原因是我使用了很多为 LaTeX 编写的软件包,而将我当前的项目切换到 XeTeX 之类的软件包可能会以微妙的方式破坏一些东西。
如果答案是“没有办法”,那也没关系。
以下是不可编译代码的最小示例:
\documentclass{article}
\usepackage{amsmath} % for the \mspace command and other things (necessity of this package not demonstrated in this minimal example)
\usepackage{dsfont} % for the \mathds command
\usepackage{txfonts} % for \coloneqq; also: if I omit this line, I get an error message saying that "Command \lhd not provided in base LaTeX2e" (I need \lhd)
\usepackage[only,llbracket,rrbracket,llparenthesis,rrparenthesis]{stmaryrd} % imports: [| |] (| |)
\usepackage[mathb]{mathabx} % for \sqbullet and \blackdiamond
% for \lcurvearrowdown:
\DeclareFontFamily{U}{MnSymbolA}{}
\DeclareFontShape{U}{MnSymbolA}{m}{n}{
<-6> MnSymbolA5
<6-7> MnSymbolA6
<7-8> MnSymbolA7
<8-9> MnSymbolA8
<9-10> MnSymbolA9
<10-12> MnSymbolA10
<12-> MnSymbolA12}{}
\DeclareFontShape{U}{MnSymbolA}{b}{n}{
<-6> MnSymbolA-Bold5
<6-7> MnSymbolA-Bold6
<7-8> MnSymbolA-Bold7
<8-9> MnSymbolA-Bold8
<9-10> MnSymbolA-Bold9
<10-12> MnSymbolA-Bold10
<12-> MnSymbolA-Bold12}{}
\DeclareSymbolFont{MnSyA}{U}{MnSymbolA}{m}{n}
\DeclareMathSymbol{\lcurvearrowdown}{\mathrel}{MnSyA}{187}
% for \sqsubseteq and \nsqsubseteq; I don't like the appearance of these symbols from txfonts, so I am using the respective MnSymbol ones, except I'm naming them \sqeq and \nsqeq
% THIS IS THE CODE BLOCK THAT FIRST MADE MY FILE UNCOMPILABLE WHEN I ADDED IT
\DeclareFontFamily{U}{MnSymbolD}{}
\DeclareFontShape{U}{MnSymbolD}{m}{n}{
<-6> MnSymbolD5
<6-7> MnSymbolD6
<7-8> MnSymbolD7
<8-9> MnSymbolD8
<9-10> MnSymbolD9
<10-12> MnSymbolD10
<12-> MnSymbolD12}{}
\DeclareFontShape{U}{MnSymbolD}{b}{n}{
<-6> MnSymbolD-Bold5
<6-7> MnSymbolD-Bold6
<7-8> MnSymbolD-Bold7
<8-9> MnSymbolD-Bold8
<9-10> MnSymbolD-Bold9
<10-12> MnSymbolD-Bold10
<12-> MnSymbolD-Bold12}{}
\DeclareSymbolFont{MnSyD}{U}{MnSymbolD}{m}{n}
\DeclareMathSymbol{\sqeq}{\mathrel}{MnSyD}{90}
\DeclareMathSymbol{\nsqeq}{\mathrel}{MnSyD}{210}
\begin{document}
\( \mathds{N} \) % WITHOUT THIS LINE, THE CODE COMPILES
\( \coloneqq \) % this line is not required to get a minimal example of uncompilable code, but I need this symbol
\( \llbracket,\rrbracket,\llparenthesis,\rrparenthesis \) % this line is not required to get a minimal example of uncompilable code, but I need these symbols
\( \sqbullet, \blackdiamond \) % this line is not required to get a minimal example of uncompilable code, but I need these symbols
\( \lcurvearrowdown \) % this line is not required to get a minimal example of uncompilable code, but I need this symbol
\( a \sqeq b \nsqeq c \) % this line is not required to get a minimal example of uncompilable code, but I need these symbols
\( \mathit{abc} \) % WITHOUT THIS LINE, THE CODE COMPILES
\( \mathsf{a} \) % WITHOUT THIS LINE, THE CODE COMPILES
\end{document}
(我知道这是一个任意的例子,但我认为它可以说明这个问题。)
答案1
如果您不需要整个字体,而只需要一些字形,您可以直接使用 usefont 调用它们。这不会增加数学字体的数量:
\documentclass[a4paper,11pt]{article}
\usepackage{mathpazo,
amsmath} %to use \text
\newcommand{\cmvarpi}{\text{\usefont{OML}{cmr}{m}{it}\symbol{36}}}
\begin{document}
\LARGE
$x=\varpi=\cmvarpi=y$
\end{document}
答案2
没有办法。即使切换到允许超过 16 个系列的引擎也不会自动帮助您,因为\mathchar
(和类似的数学命令)的格式无法处理超过 16 个系列,因此您还需要切换到扩展数学命令(例如使用unicode-math
包)。
答案3
这里我展示了如何删除预定义的数学字母表;\UndeclareMathAlphabet{\mathtt}
例如,可以 ,从而保存其中一个。不幸的是,regexpatch
由于各种原因,使用 的方法很困难。
\documentclass{article}
\usepackage{xparse,l3regex}
\makeatletter
\ExplSyntaxOn
\NewDocumentCommand{\UndeclareMathAlphabet}{m}
{
\tl_set:Nx \l_tmpa_tl {\exp_not:N \install@mathalphabet \exp_not:c {\cs_to_str:N #1~}}
\regex_replace_once:nnNT { \u{l_tmpa_tl} \cB. \c[^BE].* \cE. } {} \mv@normal { \addtocounter{mv@normal}{-1} }
\regex_replace_once:nnNT { \u{l_tmpa_tl} \cB. \c[^BE].* \cE. } {} \mv@bold { \addtocounter{mv@bold}{-1} }
}
\ExplSyntaxOff
\@onlypreamble\UndeclareMathAlphabet
\makeatother
\typeout{\expandafter\meaning\csname mv@normal\endcsname}
\typeout{\expandafter\meaning\csname mv@bold\endcsname}
\UndeclareMathAlphabet{\mathtt}
\typeout{\expandafter\meaning\csname mv@normal\endcsname}
\typeout{\expandafter\meaning\csname mv@bold\endcsname}
\UndeclareMathAlphabet{\mathsf}
\typeout{\expandafter\meaning\csname mv@normal\endcsname}
\typeout{\expandafter\meaning\csname mv@bold\endcsname}
输出为
macro:->\getanddefine@fonts \symoperators \OT1/cmr/m/n \getanddefine@fonts \sym
letters \OML/cmm/m/it \getanddefine@fonts \symsymbols \OMS/cmsy/m/n \getanddefi
ne@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\select
@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathsf {\select@g
roup \mathsf \M@OT1 \OT1/cmss/m/n }\install@mathalphabet \mathit {\select@gro
up \mathit \M@OT1 \OT1/cmr/m/it }\install@mathalphabet \mathtt {\select@group
\mathtt \M@OT1 \OT1/cmtt/m/n }
macro:->\getanddefine@fonts \symoperators \OT1/cmr/bx/n \getanddefine@fonts \sy
mletters \OML/cmm/b/it \getanddefine@fonts \symsymbols \OMS/cmsy/b/n \getanddef
ine@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\selec
t@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathsf {\select@
group \mathsf \M@OT1 \OT1/cmss/bx/n }\install@mathalphabet \mathit {\select@g
roup \mathit \M@OT1 \OT1/cmr/bx/it }\install@mathalphabet \mathtt {\select@gr
oup \mathtt \M@OT1 \OT1/cmtt/m/n }
macro:->\getanddefine@fonts \symoperators \OT1/cmr/m/n \getanddefine@fonts \sym
letters \OML/cmm/m/it \getanddefine@fonts \symsymbols \OMS/cmsy/m/n \getanddefi
ne@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\select
@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathsf {\select@g
roup \mathsf \M@OT1 \OT1/cmss/m/n }\install@mathalphabet \mathit {\select@gro
up \mathit \M@OT1 \OT1/cmr/m/it }
macro:->\getanddefine@fonts \symoperators \OT1/cmr/bx/n \getanddefine@fonts \sy
mletters \OML/cmm/b/it \getanddefine@fonts \symsymbols \OMS/cmsy/b/n \getanddef
ine@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\selec
t@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathsf {\select@
group \mathsf \M@OT1 \OT1/cmss/bx/n }\install@mathalphabet \mathit {\select@g
roup \mathit \M@OT1 \OT1/cmr/bx/it }
macro:->\getanddefine@fonts \symoperators \OT1/cmr/m/n \getanddefine@fonts \sym
letters \OML/cmm/m/it \getanddefine@fonts \symsymbols \OMS/cmsy/m/n \getanddefi
ne@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\select
@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathit {\select@g
roup \mathit \M@OT1 \OT1/cmr/m/it }
macro:->\getanddefine@fonts \symoperators \OT1/cmr/bx/n \getanddefine@fonts \sy
mletters \OML/cmm/b/it \getanddefine@fonts \symsymbols \OMS/cmsy/b/n \getanddef
ine@fonts \symlargesymbols \OMX/cmex/m/n \install@mathalphabet \mathbf {\selec
t@group \mathbf \M@OT1 \OT1/cmr/bx/n }\install@mathalphabet \mathit {\select@
group \mathit \M@OT1 \OT1/cmr/bx/it }
这表明\mathtt
和\mathsf
都已被成功删除。
答案4
我删除了我的第一个答案。可以修改 LaTeX 的内部数学结构,但正如您所说,我把它弄错了(目前没有时间修复),@egreg 有一个更强大的版本。
然而,回到使用文本字体的主题,以避免用完 16 个数学字体插槽。也许缺少数学设置的字体是数学字母而不是符号字体。如果您添加
\def\mathsf#1{\text{\textsf{#1}}}
然后,您的序言\mathsf
将使用与以前相同的字体,但通过嵌套文本框,并且您的文件处理不会出现错误。