我正在努力让 XeLaTeX 在数学模式下给我粗体希腊符号,但我不知道如何在序言中正确指定内容。我花了几个小时在谷歌上搜索和浏览这个论坛,虽然我找到了很多帮助我消除编译错误的极度提示,但我仍然没有找到。
我刚刚从 Rotis Semi Sans 系列购买了希腊字体,所以我现在有两个文件 RotisSemiSansProGrk-Italic.otf 和 RotisSemiSansProGrk-Bold.otf,我认为它们足以满足我的目的:我希望数学模式下的非粗体拉丁字母和希腊字母为斜体,而粗体拉丁字母和希腊字母(仍在数学模式下)为直立。以下是我最好的尝试,它在编译时没有出现任何错误,并且就非粗体拉丁字母和希腊字母以及粗体拉丁字母而言运行良好,但就是无法给我直立的粗体希腊符号:
\documentclass{article}
\usepackage{mathspec}
\setprimaryfont{Rotis Semi Sans Std}
\setmathsfont(Greek)[Lowercase=Regular]{RotisSemiSansProGrk-Italic}
%\setmathsfont(Greek)[Lowercase=Regular]{RotisSemiSansProGrk-Bold}
\begin{document}
This is some sample text.
\textbf{This is some sample text in bold.}
This is a pair of equations with italic Latin letters:
%%
\[
a+2b=3c,\quad B=S
\]
This is a pair of equations with upright and bold Latin letters:
%%
\[
\mathbf{a}+2\mathbf{b}=3\mathbf{c},\quad \mathbf{B}=\mathbf{S}
\]
This is a pair of equations with italic Greek letters:
%%
\[
\alpha+2\beta=3\gamma,\quad \beta=\Sigma
\]
This is a pair of equations with Greek letters, which I'd like to be upright and bold:
%%
\[
\mathbf{\alpha}+2\mathbf{\beta}=3\mathbf{\gamma},\quad \mathbf{\beta}=\mathbf{\Sigma}
\]
\fontspec{RotisSemiSansProGrk-Bold} There I can get bold upright Greek, but not in math mode: α β γ Σ
\end{document}
输出如下:
如果我取消注释序言中的注释行,我会在方程式中获得粗体希腊符号,但任何希腊符号都会变成粗体。我不知道如何告诉 XeLaTex 使用一个 .otf 文件作为斜体,另一个文件作为粗体。
我考虑过使用unicode 数学,但不支持 Rotis Semi Sans。
欢迎任何帮助!
答案1
一种类似黑客的解决方案,使用tikz
额外textgreek
的包,但独立于您选择的字体(据我所知)。
额外:一种对厚度的控制。
\documentclass{article}
%%% Addded these packages
\usepackage{tikz}
\usepackage[euler]{textgreek}
\usepackage{bm}
%%%End of packages added
\usepackage{mathspec}
\setromanfont{Linux Libertine O}
\newfontfamily{\newfont}{Liberation Serif}
\setmathsfont(Greek)[Lowercase=Regular]{Liberation Serif-Italic}
%%%Added this form Joseph
%%% Joseph Wright's code from here: https://tex.stackexchange.com/a/42332/120578
\makeatletter
\newcommand{\removeabs}[1]{%
\ifcat\relax\noexpand#1%
\expandafter\removeabs@aux@i
\fi
#1%
}
\newcommand*{\removeabs@aux@i}{%
\romannumeral
\if\string\ \removeabs@aux@ii\fi
\expandafter\removeabs@aux@iii\string
}
\newcommand{\removeabs@aux@ii}{}
\long\def\removeabs@aux@ii#1\removeabs@aux@iii{%
-\number\fi\expandafter\z@
}
\newcommand{\removeabs@aux@iii}[1]{\z@}
\makeatother
%%%End of Josheph Wrigth's code
\newcommand{\mybold}[2][0.06]{\tikz[remember picture,inner sep=0,anchor=base,baseline]%
\node(A1){$#2$};%
\foreach \i in{-#1,0,#1}{%
\begin{tikzpicture}[inner sep=0,remember picture,overlay,anchor=center, baseline]\node[xshift=\i pt,yshift=-\i pt] at(A1){$#2$};%
\node[xshift=-\i pt,yshift=\i pt] at(A1){$#2$};%
\end{tikzpicture}}%
}%
%%% Added this code of mine:
\newcommand{\myUpbold}[2][0.06]{\tikz[remember picture,inner sep=0,anchor=base,baseline]%
\node(A1){\csname text\removeabs{#2}\endcsname};%
\foreach \i in{-#1,0,#1}{%
\begin{tikzpicture}[inner sep=0,remember picture,overlay,anchor=center,baseline]\node[xshift=\i pt,yshift=-\i pt] at(A1){\csname text\removeabs{#2}\endcsname};%
\node[xshift=-\i pt,yshift=\i pt] at(A1){\csname text\removeabs{#2}\endcsname};%
\end{tikzpicture}}%
}%
%%%End my code
\begin{document}
This is some sample text.
\textbf{This is some sample text in bold.}
This is a pair of equations with italic Latin letters:
%%
\[
a+2b=3c,\quad B=S
\]
This is a pair of equations with upright and bold Latin letters:
%%
\[
\mathbf{a}+2\mathbf{b}=3\mathbf{c},\quad \mathbf{B}=\mathbf{S}
\]
This is a pair of equations with italic Greek letters:
%%
\[
\alpha+2\beta=3\gamma,\quad \beta=\Sigma
\]
This is a pair of equations with Greek letters, which I'd like to be upright and semi-bold:
%%
\newfont\selectfont
\def\mathbf#1{\myUpbold[0.005]{#1}}
\[
\mathbf{\alpha}+2\mathbf{\beta}=3\mathbf{\gamma},\quad \mathbf{\beta}=\mathbf{\Sigma}
\]
This is a pair of equations with Greek letters, which I'd like to be upright and bold:
%%
\newfont\selectfont
\def\mathbf#1{\myUpbold{#1}}
\[
\mathbf{\alpha}+2\mathbf{\beta}=3\mathbf{\gamma},\quad \mathbf{\beta}=\mathbf{\Sigma}
\]
This is a pair of equations with Greek letters, which are italic and semi-bold:
%%
\newfont\selectfont
\def\mathbf#1{\mybold[0.005]{#1}}
\[
\mathbf{\alpha}+2\mathbf{\beta}=3\mathbf{\gamma},\quad \mathbf{\beta}=\mathbf{\Sigma}
\]
This is a pair of equations with Greek letters, which are italic and really-bold:
%%
\newfont\selectfont
\def\mathbf#1{\mybold[0.09]{#1}}
\[
\mathbf{\alpha}+2\mathbf{\beta}=3\mathbf{\gamma},\quad \mathbf{\beta}=\mathbf{\Sigma}
\]
{ \bfseries
There I can get bold upright Greek: α β γ Σ
}
\end{document}
这个想法是我的一个旧想法,它是这样的: https://tex.stackexchange.com/a/396336/120578
但这次需要更多的黑客攻击。
使用了 Joseph Wright 的代码: https://tex.stackexchange.com/a/42332/120578
输出:
答案2
@科莱格尔很好的解决方案,谢谢!我没有考虑过“穷人的大胆”选项,但它给出了相当令人信服的结果。我只是将序言中的字体选择更改为如下:
\setprimaryfont{Rotis Semi Sans Std}
\newfontfamily{\newfont}{Rotis Semi Sans Std}
\setmathsfont(Greek)[Lowercase=Regular]{RotisSemiSansProGrk-Italic}
下面是带有希腊符号的方程的输出(我在方程中添加了指数以显示它们与希腊字母的正确间距):