当文本为斜体时,自动直立数学

当文本为斜体时,自动直立数学

这在某种程度上是对这一问题关于正直的数学。

当我使用带有斜体语句的定理类环境时,我希望数学(本质上是变量名)是直立的。19 世纪的某些数学出版物曾经以这种方式完成,我希望重现这种外观。

  1. 我可以在公式中任何需要的地方使用 \mathrm。

  2. 我可以删除语句中仅使用孤立字母的所有位置的 $...$,并用适当的命令将它们括起来。

  3. 我可以使用mathastextLaTeX 包及其“柔和”选项

  1. 很遗憾,所有公式都要为定理的特殊情况付费

  2. 这也不太好非TeX定理中的数学变量也是如此,也不利于校对、剪切和粘贴。

  3. 由于该软件包与 mathfonts、mathversions 的所有交互,使用该mathastext软件包的后果相当严重,并且对于使用了许多软件包的大型文档来说似乎有点风险。正如其作者自己所写:

    如果没有 subdued 选项,则 mathastextification 默认适用于整个文档(也可以在序言中定义其他数学版本);柔和的选项 mathastextification 仅在与标准和粗体版本不同的数学版本中完成。

    前面的描述实际上有点乐观:mathastext 最初并不是为允许其操作完全取消而编写的,而要实现这一点需要完全重写大部分代码。为了真正显示数学(几乎)就像 mathastext 未加载一样,至少还必须使用 defaultmathsizes 选项。这还不够,[...]

那么,有没有一种简单的方法可以定义一个定理环境,让(简单的)数学变得直立?


编辑

感谢 jfbu 的回答,这里有一个直观的说明。我想要的案例是最后一个。

定理斜体和直体的各种组合演示

答案1

这是我在评论中解释的内容。我还必须为拉丁字母声明一个符号字体,因为标准 LaTeX 中有一些东西,比如rightharpoonup字母中的符号;我们不想将它们重新分配给具有其他编码的字体。

更新:在最后添加了LGR评论中提到的必要代码。

\documentclass{article}
\DeclareSymbolFont {greekletters}{OML}{cmm}{m}{it}
\DeclareSymbolFont {latinletters}{OML}{cmm}{m}{it}
\DeclareMathVersion {upright}
\SetSymbolFont {latinletters}{upright}{OT1}{cmr}{m}{n}
\SetSymbolFont {greekletters}{upright}{U}{txmia}{m}{it} % using the upright
                                % Greek letters provided with the txfonts
                                % package 

\DeclareMathSymbol{a}{\mathalpha}{latinletters}{`a}
\DeclareMathSymbol{b}{\mathalpha}{latinletters}{`b}
\DeclareMathSymbol{c}{\mathalpha}{latinletters}{`c}
\DeclareMathSymbol{d}{\mathalpha}{latinletters}{`d}
\DeclareMathSymbol{e}{\mathalpha}{latinletters}{`e}
\DeclareMathSymbol{f}{\mathalpha}{latinletters}{`f}
\DeclareMathSymbol{g}{\mathalpha}{latinletters}{`g}
\DeclareMathSymbol{h}{\mathalpha}{latinletters}{`h}
\DeclareMathSymbol{i}{\mathalpha}{latinletters}{`i}
\DeclareMathSymbol{j}{\mathalpha}{latinletters}{`j}
\DeclareMathSymbol{k}{\mathalpha}{latinletters}{`k}
\DeclareMathSymbol{l}{\mathalpha}{latinletters}{`l}
\DeclareMathSymbol{m}{\mathalpha}{latinletters}{`m}
\DeclareMathSymbol{n}{\mathalpha}{latinletters}{`n}
\DeclareMathSymbol{o}{\mathalpha}{latinletters}{`o}
\DeclareMathSymbol{p}{\mathalpha}{latinletters}{`p}
\DeclareMathSymbol{q}{\mathalpha}{latinletters}{`q}
\DeclareMathSymbol{r}{\mathalpha}{latinletters}{`r}
\DeclareMathSymbol{s}{\mathalpha}{latinletters}{`s}
\DeclareMathSymbol{t}{\mathalpha}{latinletters}{`t}
\DeclareMathSymbol{u}{\mathalpha}{latinletters}{`u}
\DeclareMathSymbol{v}{\mathalpha}{latinletters}{`v}
\DeclareMathSymbol{w}{\mathalpha}{latinletters}{`w}
\DeclareMathSymbol{x}{\mathalpha}{latinletters}{`x}
\DeclareMathSymbol{y}{\mathalpha}{latinletters}{`y}
\DeclareMathSymbol{z}{\mathalpha}{latinletters}{`z}
\DeclareMathSymbol{A}{\mathalpha}{latinletters}{`A}
\DeclareMathSymbol{B}{\mathalpha}{latinletters}{`B}
\DeclareMathSymbol{C}{\mathalpha}{latinletters}{`C}
\DeclareMathSymbol{D}{\mathalpha}{latinletters}{`D}
\DeclareMathSymbol{E}{\mathalpha}{latinletters}{`E}
\DeclareMathSymbol{F}{\mathalpha}{latinletters}{`F}
\DeclareMathSymbol{G}{\mathalpha}{latinletters}{`G}
\DeclareMathSymbol{H}{\mathalpha}{latinletters}{`H}
\DeclareMathSymbol{I}{\mathalpha}{latinletters}{`I}
\DeclareMathSymbol{J}{\mathalpha}{latinletters}{`J}
\DeclareMathSymbol{K}{\mathalpha}{latinletters}{`K}
\DeclareMathSymbol{L}{\mathalpha}{latinletters}{`L}
\DeclareMathSymbol{M}{\mathalpha}{latinletters}{`M}
\DeclareMathSymbol{N}{\mathalpha}{latinletters}{`N}
\DeclareMathSymbol{O}{\mathalpha}{latinletters}{`O}
\DeclareMathSymbol{P}{\mathalpha}{latinletters}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{latinletters}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{latinletters}{`R}
\DeclareMathSymbol{S}{\mathalpha}{latinletters}{`S}
\DeclareMathSymbol{T}{\mathalpha}{latinletters}{`T}
\DeclareMathSymbol{U}{\mathalpha}{latinletters}{`U}
\DeclareMathSymbol{V}{\mathalpha}{latinletters}{`V}
\DeclareMathSymbol{W}{\mathalpha}{latinletters}{`W}
\DeclareMathSymbol{X}{\mathalpha}{latinletters}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{latinletters}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{latinletters}{`Z}
\DeclareMathSymbol{\alpha}{\mathord}{greekletters}{"0B}
\DeclareMathSymbol{\beta}{\mathord}{greekletters}{"0C}
\DeclareMathSymbol{\gamma}{\mathord}{greekletters}{"0D}
\DeclareMathSymbol{\delta}{\mathord}{greekletters}{"0E}
\DeclareMathSymbol{\epsilon}{\mathord}{greekletters}{"0F}
\DeclareMathSymbol{\zeta}{\mathord}{greekletters}{"10}
\DeclareMathSymbol{\eta}{\mathord}{greekletters}{"11}
\DeclareMathSymbol{\theta}{\mathord}{greekletters}{"12}
\DeclareMathSymbol{\iota}{\mathord}{greekletters}{"13}
\DeclareMathSymbol{\kappa}{\mathord}{greekletters}{"14}
\DeclareMathSymbol{\lambda}{\mathord}{greekletters}{"15}
\DeclareMathSymbol{\mu}{\mathord}{greekletters}{"16}
\DeclareMathSymbol{\nu}{\mathord}{greekletters}{"17}
\DeclareMathSymbol{\xi}{\mathord}{greekletters}{"18}
\DeclareMathSymbol{\pi}{\mathord}{greekletters}{"19}
\DeclareMathSymbol{\rho}{\mathord}{greekletters}{"1A}
\DeclareMathSymbol{\sigma}{\mathord}{greekletters}{"1B}
\DeclareMathSymbol{\tau}{\mathord}{greekletters}{"1C}
\DeclareMathSymbol{\upsilon}{\mathord}{greekletters}{"1D}
\DeclareMathSymbol{\phi}{\mathord}{greekletters}{"1E}
\DeclareMathSymbol{\chi}{\mathord}{greekletters}{"1F}
\DeclareMathSymbol{\psi}{\mathord}{greekletters}{"20}
\DeclareMathSymbol{\omega}{\mathord}{greekletters}{"21}
\DeclareMathSymbol{\varepsilon}{\mathord}{greekletters}{"22}
\DeclareMathSymbol{\vartheta}{\mathord}{greekletters}{"23}
\DeclareMathSymbol{\varpi}{\mathord}{greekletters}{"24}
\DeclareMathSymbol{\varrho}{\mathord}{greekletters}{"25}
\DeclareMathSymbol{\varsigma}{\mathord}{greekletters}{"26}
\DeclareMathSymbol{\varphi}{\mathord}{greekletters}{"27}

\begin{document}

This is standard: $\alpha^n+\beta^n+x^n+y^n=z^n$.

\mathversion {upright}

This is upright: $\alpha^n+\beta^n+x^n+y^n=z^n$.

\mathversion {normal}

This is standard:  $\alpha^n+\beta^n+x^n+y^n=z^n$.


\end{document}

直立

现在我们可以为 做这些LGR。这变得很复杂,因为我还想定义\Alpha\Beta等……它们通常来自拉丁字体,但由于它们在LGR编码字体中,所以我需要让它们在标准的非直立数学中也可用(然后在字体中选择它们cmr,假设标准设置)。

\DeclareFontEncoding {LGR}{}{}
\SetSymbolFont {greekletters}{upright}{LGR}{cmr}{m}{n} 

% (the LGR encoded CMR font comes with the cbfonts package, and is
% pre-installed at least in TeXLive and presumably also other TeX
% distributions)

% This list defines also `capital' Greek letters,
% including the ones usually represented by Latin letters.
% missing: \varphi, \varepsilon, \varpi, \vartheta, \varrho

%% 'uppercase'
\DeclareMathSymbol {\Alphalgr}   {\mathord}{greekletters}{65}
\DeclareMathSymbol {\Betalgr}    {\mathord}{greekletters}{66}
\DeclareMathSymbol {\Gammalgr}   {\mathord}{greekletters}{71}
\DeclareMathSymbol {\Deltalgr}   {\mathord}{greekletters}{68}
\DeclareMathSymbol {\Epsilonlgr} {\mathord}{greekletters}{69}
\DeclareMathSymbol {\Zetalgr}    {\mathord}{greekletters}{90}
\DeclareMathSymbol {\Etalgr}     {\mathord}{greekletters}{72}
\DeclareMathSymbol {\Thetalgr}   {\mathord}{greekletters}{74}
\DeclareMathSymbol {\Iotalgr}    {\mathord}{greekletters}{73}
\DeclareMathSymbol {\Kappalgr}   {\mathord}{greekletters}{75}
\DeclareMathSymbol {\Lambdalgr}  {\mathord}{greekletters}{76}
\DeclareMathSymbol {\Mulgr}      {\mathord}{greekletters}{77}
\DeclareMathSymbol {\Nulgr}      {\mathord}{greekletters}{78}
\DeclareMathSymbol {\Xilgr}      {\mathord}{greekletters}{88}
\DeclareMathSymbol {\Omicronlgr} {\mathord}{greekletters}{79}
\DeclareMathSymbol {\Pilgr}      {\mathord}{greekletters}{80}
\DeclareMathSymbol {\Rholgr}     {\mathord}{greekletters}{82}
\DeclareMathSymbol {\Sigmalgr}   {\mathord}{greekletters}{83}
\DeclareMathSymbol {\Taulgr}     {\mathord}{greekletters}{84}
\DeclareMathSymbol {\Upsilonlgr} {\mathord}{greekletters}{85}
\DeclareMathSymbol {\Philgr}     {\mathord}{greekletters}{70}
\DeclareMathSymbol {\Chilgr}     {\mathord}{greekletters}{81}
\DeclareMathSymbol {\Psilgr}     {\mathord}{greekletters}{89}
\DeclareMathSymbol {\Omegalgr}   {\mathord}{greekletters}{87}
\DeclareMathSymbol {\Digammalgr} {\mathord}{greekletters}{195}
%% 'lowercase'
\DeclareMathSymbol {\alphalgr}   {\mathord}{greekletters}{97}
\DeclareMathSymbol {\betalgr}    {\mathord}{greekletters}{98}
\DeclareMathSymbol {\gammalgr}   {\mathord}{greekletters}{103}
\DeclareMathSymbol {\deltalgr}   {\mathord}{greekletters}{100}
\DeclareMathSymbol {\epsilonlgr} {\mathord}{greekletters}{101}
\DeclareMathSymbol {\zetalgr}    {\mathord}{greekletters}{122}
\DeclareMathSymbol {\etalgr}     {\mathord}{greekletters}{104}
\DeclareMathSymbol {\thetalgr}   {\mathord}{greekletters}{106}
\DeclareMathSymbol {\iotalgr}    {\mathord}{greekletters}{105}
\DeclareMathSymbol {\kappalgr}   {\mathord}{greekletters}{107}
\DeclareMathSymbol {\lambdalgr}  {\mathord}{greekletters}{108}
\DeclareMathSymbol {\mulgr}      {\mathord}{greekletters}{109}
\DeclareMathSymbol {\nulgr}      {\mathord}{greekletters}{110}
\DeclareMathSymbol {\xilgr}      {\mathord}{greekletters}{120}
\DeclareMathSymbol {\omicronlgr} {\mathord}{greekletters}{111}
\DeclareMathSymbol {\pilgr}      {\mathord}{greekletters}{112}
\DeclareMathSymbol {\rholgr}     {\mathord}{greekletters}{114}
\DeclareMathSymbol {\varsigmalgr}{\mathord}{greekletters}{99}
\DeclareMathSymbol {\sigmalgr}   {\mathord}{greekletters}{115}
\DeclareMathSymbol {\taulgr}     {\mathord}{greekletters}{116}
\DeclareMathSymbol {\upsilonlgr} {\mathord}{greekletters}{117}
\DeclareMathSymbol {\philgr}     {\mathord}{greekletters}{102}
\DeclareMathSymbol {\chilgr}     {\mathord}{greekletters}{113}
\DeclareMathSymbol {\psilgr}     {\mathord}{greekletters}{121}
\DeclareMathSymbol {\omegalgr}   {\mathord}{greekletters}{119}
\DeclareMathSymbol {\digammalgr} {\mathord}{greekletters}{147}

\makeatletter

% \let\Alphastd A\let\Betastd B\let\Epsilonstd E\let\Zetastd Z%
% \let\Etastd N\let\Iotastd I\let\Kappastd K\let\Mustd M%
% \let\Nustd N\let\Omicronstd O\let\Rhostd P\let\Taustd T%
% \let\Chistd X\let\Digammastd F%
% but we wan't them upright (as the other capital Greek letters), hence:
\DeclareMathSymbol{\Alphastd}  {\mathord}{operators}{`A}
\DeclareMathSymbol{\Betastd}   {\mathord}{operators}{`B}
\DeclareMathSymbol{\Epsilonstd}{\mathord}{operators}{`E}
\DeclareMathSymbol{\Digammastd}{\mathord}{operators}{`F}
\DeclareMathSymbol{\Etastd}    {\mathord}{operators}{`H} % not sure here
\DeclareMathSymbol{\Iotastd}   {\mathord}{operators}{`I}
\DeclareMathSymbol{\Kappastd}  {\mathord}{operators}{`K}
\DeclareMathSymbol{\Mustd}     {\mathord}{operators}{`M}
\DeclareMathSymbol{\Nustd}     {\mathord}{operators}{`N}
\DeclareMathSymbol{\Omicronstd}{\mathord}{operators}{`O}
\DeclareMathSymbol{\Rhostd}    {\mathord}{operators}{`P}
\DeclareMathSymbol{\Taustd}    {\mathord}{operators}{`T}
\DeclareMathSymbol{\Chistd}    {\mathord}{operators}{`X}
\DeclareMathSymbol{\Zetastd}   {\mathord}{operators}{`Z}

\let\digammastd f% <- not satisfactory ?
\let\omicronstd o%

\@for\@tempa:=alpha,beta,gamma,delta,epsilon,zeta,eta,theta,%
  iota,kappa,lambda,mu,nu,xi,pi,rho,varsigma,sigma,%
  tau,upsilon,phi,chi,psi,omega,Gamma,Delta,Theta,Lambda,%
  Xi,Pi,Sigma,Upsilon,Phi,Psi,Omega\do{\expandafter\let
  \csname\@tempa std\expandafter\endcsname\csname\@tempa\endcsname}%

\newcommand*\lgrgreek{%
  \@for\@tempa:=alpha,beta,gamma,delta,epsilon,zeta,eta,theta,%
  iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,varsigma,sigma,%
  tau,upsilon,phi,chi,psi,omega,digamma,Digamma,Alpha,Beta,%
  Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,%
  Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,%
  Omega\do{\expandafter\let\csname\@tempa\expandafter\endcsname
    \csname\@tempa lgr\endcsname}}%

\newcommand*\stdgreek{%
  \@for\@tempa:=alpha,beta,gamma,delta,epsilon,zeta,eta,theta,%
  iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,varsigma,sigma,%
  tau,upsilon,phi,chi,psi,omega,digamma,Digamma,Alpha,Beta,%
  Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,%
  Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,%
  Omega\do{\expandafter\let\csname\@tempa\expandafter\endcsname
    \csname\@tempa std\endcsname}}%

\newcommand*\checkgreekletters{%
  \@for\@tempa:=alpha,beta,gamma,delta,epsilon,zeta,eta,theta,%
  iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,varsigma,sigma,%
  tau,upsilon,phi,chi,psi,omega,digamma,Digamma,Alpha,Beta,%
  Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,%
  Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,%
  Omega\do{\makebox[.75em]{$\csname\@tempa\endcsname$}, }}

\makeatother
\stdgreek % initializes \Alpha, etc...


\begin{document}

This is standard: $\alpha^n+\beta^n+x^n+y^n=z^n$.

\checkgreekletters

\mathversion {upright}\lgrgreek

This is upright: $\alpha^n+\beta^n+x^n+y^n=z^n$.

\checkgreekletters

\mathversion {normal}\stdgreek

This is standard:  $\alpha^n+\beta^n+x^n+y^n=z^n$.

\checkgreekletters

\end{document}

直立,带 lgr

相关内容