使用 [lua|xe]latex 的直立无衬线大写希腊字母

使用 [lua|xe]latex 的直立无衬线大写希腊字母

提供代码

\documentclass{article}
\pagestyle{empty}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% scaling somewhat ok.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\newcommand{\concreteSort}[1]{\mathsf{#1}}
\begin{document}
\begin{tabular}{ll}
Normal math italic Latin:& \(Sigma\).\\ %%% product of five variables S, i, g, m, a.
Normal math italic Greek:& \(\Sigma\).\\ %%% a single variable.
Upright sans-serif math Latin:&\(\concreteSort{Sigma}\).\\%%% a constant with a fixed meaning.
Upright sans-serif math Greek:&\(\concreteSort{\upSigma}\).%%% another constant with a fixed meaning. Where to get an upright sans-serif math Σ without changing the rest?
\end{tabular}
\end{document}

导致xelatex

在此处输入图片描述

如上所示,最后一个 Σ 有衬线。如何在不改变其余部分的情况下去除直立大写希腊字母的衬线,即保持其余文本和数学的格式?是的,我们希望保留[xe|lua]latex。我预计需要不同的字体,但哪种字体?如何仅为直立大写希腊字母切换它?理想情况下,\concreteSort应该为拉丁文和大写希腊文产生相同的(直立、无衬线)格式,但事实并非如此。

编辑:灵感来自http://tex.stackexchange.com/a/537218,我喂

\documentclass{standalone}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% %%% this scaling factor is a middle way between MatchUppercase and MatchLowercase.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\setmathfontface\mathsans{TeX Gyre Heros}%%% suggested by http://tex.stackexchange.com/a/537218
\begin{document}\noindent%
\begin{tabular}{@{}rl@{}}
  \verb!\(\mathsf{\mupSigma}\)!:&\(\mathsf{\mupSigma}\)\\
  \verb!\(\mathsans{\mupSigma}\)!:&\(\mathsans{\mupSigma}\)
\end{tabular}
\end{document}

xelatex并得到\mathsans{\mupSigma}大于\mathsf{\mupSigma}

不同尺寸

为什么?对于具有固定含义的标识符 Σ,我需要哪一个?以下是一些测试代码:

\documentclass{article}
\pagestyle{empty}
\usepackage[ngerman]{babel}
\usepackage{mathtools}%%% loads amsmath internally
\mathtoolsset{mathic=true} %%% See http://tex.stackexchange.com/a/3496
\usepackage[math-style=ISO]{unicode-math}%%% In general, we wish to have ISO style.
\defaultfontfeatures{Scale=MatchUppercase}
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}%%% Times in general.
\setsansfont{TeX Gyre Heros} %[Scale=0.88]%%% this scaling factor is a middle way between MatchUppercase and MatchLowercase.
\setmonofont{TeX Gyre Cursor}%%% no explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}%%% Times-like math font.
\setmathfontface\mathsans{TeX Gyre Heros}%%% suggested by http://tex.stackexchange.com/a/537218
\newcommand{\concreteSortSf}[1]{\mathsf{#1}}
\newcommand{\concreteSortSfup}[1]{\mathsfup{#1}}
\newcommand{\concreteSortSans}[1]{\mathsans{#1}}
\begin{document}\noindent%
\begin{tabular}{@{}rl@{}}
  \verb!\mathsf!: & Serif \(\mathsf{sans}\) serif.\\
  \verb!\mathsans!: & Serif \(\mathsans{sans}\) serif.
\end{tabular}

With \verb!\mathsf!:\\
Consider the sort \(\concreteSortSf{Queue}\,\concreteSortSf{\mupSigma}\) and the function signature
\[f\colon\ \,\concreteSortSf{Queue}\,\concreteSortSf{\mupSigma}\ \to\ \concreteSortSf{Stack}\,\concreteSortSf{\mupSigma}\ .\]

With \verb!\mathsfup!:\\
Consider the sort \(\concreteSortSfup{Queue}\,\concreteSortSfup{\mupSigma}\) and the function signature\[f\colon\ \,\concreteSortSfup{Queue}\,\concreteSortSfup{\mupSigma}\ \to\ \concreteSortSfup{Stack}\,\concreteSortSfup{\mupSigma}\ .\]

With \verb!\mathsans!:\\
Consider the sort \(\concreteSortSans{Queue}\,\concreteSortSans{\mupSigma}\) and the function signature\[f\colon\ \,\concreteSortSans{Queue}\,\concreteSortSans{\mupSigma}\ \to\ \concreteSortSans{Stack}\,\concreteSortSans{\mupSigma}\ .\]
\end{document}

结果对于\mathsf和是好的\mathsans(问题仍然是使用哪一个,至少在传统上),而对于是坏的\mathsfup,因为它产生了倾斜的

答案1

\concreteSort还可以定义修改希腊字母命令的含义。

定义中的列表\changegreek不完整,请填写缺失的字母。

这个想法是变成\Sigma\symsfupx{\mupSigma}它将使用 sans 字体中的字母(当然,假设它有它;否则你需要另一个有它的 Helvetica 克隆)。

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{mathtools}

\usepackage[math-style=ISO]{unicode-math}

\setmainfont{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}[Scale=MatchLowercase]
\setmonofont{TeX Gyre Cursor}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface{\symsfupx}{TeX Gyre Heros}[Scale=MatchLowercase]

\mathtoolsset{mathic=true}

\newcommand{\concreteSort}[1]{\symsfup{\changegreek#1}}

\ExplSyntaxOn
\cs_new_protected:Npn \changegreek
 {
  \clist_map_inline:nn { \Alpha,\Beta,\Gamma,\Delta,\Sigma } % <--- add
   {
    \cs_set_protected:Npn ##1 { \symsfupx{\use:c{mup \cs_to_str:N ##1 }} }
   }
 }
\ExplSyntaxOff


\begin{document}

\begin{tabular}{ll}
Normal math italic Latin:& \(Sigma\).\\
Normal math italic Greek:& \(\Sigma\).\\
Upright sans-serif math Latin:&\(\concreteSort{Sigma}\).\\
Upright sans-serif math Greek:&\(\concreteSort{\Sigma}\).\\
\end{tabular}

\end{document}

在此处输入图片描述

答案2

Unicode 中没有无衬线希腊数学字母表,但unicode-math允许您使用 定义新的数学字母表\setmathfontface。请参阅手册第 4.4 节了解详情。

另一个选择是选择 sans-math 版本。

显示两种方法的 MWE:

\documentclass{book}
\usepackage{amsmath} % Only older installations need this.
\usepackage[math-style=ISO]{unicode-math}

\defaultfontfeatures{Scale=MatchUppercase}
\setmainfont{TeX Gyre Termes}[Scale=1.0]
\setsansfont{TeX Gyre Heros}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface\mathsans{TeX Gyre Heros}
\setmathfont[version=sans]{FiraMath-Regular.otf}

\newcommand\sansmath{\mathversion{sans}}
\newcommand\sanssymbol[1]{\text{\mathversion{sans}\ensuremath{#1}}}

\begin{document}

Text Sigma: {\mupSigma} (TeX Gyre Termes)

Math upright Sigma: \(\symup\Sigma\) (TG Termes Math)

Summation symbol: \(\sum\)

Sans face: \(\mathsans{\mupSigma}\) (TeX Gyre Heros)

Sans version: \(\sanssymbol{\symup\Sigma}\) (Fira Math)

\end{document}

字体示例

\mathsans这将添加一个类似于\mathsfup\sansmath类似于\boldmath\sanssymbol类似于 的新命令\boldsymbol。您可能需要将此版本的 包装\sanssymbol在诸如\mathbin或 之类的命令中\mathrel,以获得除字母之外的其他内容的正确间距。

特别是,\mathop{\sanssymbol{\sum}}有效。如果你只是希望所有求和符号都是无衬线的,你可以使用\setmathfont{Fira Math}[range=\sum] 反而[version=sans]

PS:加载时选择的是ISO风格unicode-math,但是在ISO风格下,直立的希腊大写字母应该是倾斜的,除非它们是常量。

PPS:该\mathsfup命令在这种情况下会起作用。它会加载您用 加载的字体\setsansfont。理论上,它适用于数学模式下的单词和短语,例如,如果您尝试将其用于连续的符号,您可能会得到连字。

用于张量符号等的命令是\symsfup,但它不适用于此,因为 Unicode 中目前没有希腊数学无衬线字母。

预计到达时间

\sansmath对和的更好定义\sanssymbol基于amsbsy.sty

\makeatletter
\newcommand\sansmath{\mathversion{sans}}
%% Based on the definition of \boldsymbol from amsbsy.sty"
\DeclareRobustCommand{\sanssymbol}[1]{%
  \begingroup%
  \let\@nomath\@gobble \mathversion{sans}%
  \math@atom{#1}{%
  \mathchoice%
    {\hbox{$\m@th\displaystyle#1$}}%
    {\hbox{$\m@th\textstyle#1$}}%
    {\hbox{$\m@th\scriptstyle#1$}}%
    {\hbox{$\m@th\scriptscriptstyle#1$}}}%
  \endgroup}
\makeatother

相关内容