![如何才能使长音符变得没那么宽呢?](https://linux22.com/image/317908/%E5%A6%82%E4%BD%95%E6%89%8D%E8%83%BD%E4%BD%BF%E9%95%BF%E9%9F%B3%E7%AC%A6%E5%8F%98%E5%BE%97%E6%B2%A1%E9%82%A3%E4%B9%88%E5%AE%BD%E5%91%A2%EF%BC%9F.png)
所有字符上的长音符号看起来都很宽,但字母 i 上的长音符号尤其宽。是否可以将它们缩小一点?
\documentclass{article}
\begin{document}
Tac\=e, M\=arc\=o, \=unus, f\=\i li\=\i?
\end{document}
答案1
您可以定义一个短的,与较长的相匹配,并且非常适合,如下i
所示:
\newcommand{\shortmacron}{%
\makebox[0pt][l]{%
\rule[1.3ex]{0.2em}{0.035em}%
}%
}
另一种方法是定义一个聪明的自动调整长度的版本。我还将这个设置得稍微低一些,以尽量减少与f
\newlength\tmp
\newcommand{\smartmacron}[1]{%
\settowidth{\tmp}{#1}%
\makebox[\tmp][c]{%
\rule[1.2ex]{0.6\tmp}{0.035em}%
}\kern-\tmp#1%
}
使用该xstring
包检查后面跟着哪个字母,我们可以更加智能地定义宏,并将长音符更好地对齐在字母的顶部:
\usepackage{xstring}
\newlength\tmpa
\newlength\tmpb
\newlength\tmpc
\newcommand{\supersmartmacron}[1]{%
\settowidth{\tmpa}{#1}% width of letter
\setlength{\tmpb}{0em}% x-shift
\setlength{\tmpc}{1.23ex}% raise
\IfStrEqCase{#1}{%
{a} {\setlength{\tmpb}{-0.04em}}%
{e} {\setlength{\tmpb}{-0.01em}}%
{i} {\setlength{\tmpb}{-0.045em}\setlength{\tmpc}{1.8ex}}%
{\i}{\setlength{\tmpb}{-0.045em}}%
{o} {\setlength{\tmpb}{-0.01em}}%
{u} {\setlength{\tmpb}{-0.04em}}%
}
\makebox[\tmpa][c]{%
\kern\tmpb\rule[\tmpc]{0.6\tmpa}{0.035em}%
}\kern-\tmpa#1%
}
当然\tmpa
,延长的正确值取决于所选的字体。\tmpb
\tmpc
结果和演示代码
(原始版马克龙、简短版马克龙、智能版马克龙、超级智能版马克龙)
\documentclass{article}
\newcommand{\shortmacron}{%
\makebox[0pt][l]{%
\rule[1.3ex]{0.2em}{0.035em}%
}%
}
\newlength\tmp
\newcommand{\smartmacron}[1]{%
\settowidth{\tmp}{#1}%
\makebox[\tmp][c]{%
\rule[1.2ex]{0.6\tmp}{0.035em}%
}\kern-\tmp#1%
}
\usepackage{xstring}
\newlength\tmpa
\newlength\tmpb
\newlength\tmpc
\newcommand{\supersmartmacron}[1]{%
\settowidth{\tmpa}{#1}% width of letter
\setlength{\tmpb}{0em}% x-shift
\setlength{\tmpc}{1.23ex}% raise
\IfStrEqCase{#1}{%
{a} {\setlength{\tmpb}{-0.04em}}%
{e} {\setlength{\tmpb}{-0.01em}}%
{i} {\setlength{\tmpb}{-0.045em}\setlength{\tmpc}{1.8ex}}%
{\i}{\setlength{\tmpb}{-0.045em}}%
{o} {\setlength{\tmpb}{-0.01em}}%
{u} {\setlength{\tmpb}{-0.04em}}%
}
\makebox[\tmpa][c]{%
\kern\tmpb\rule[\tmpc]{0.6\tmpa}{0.035em}%
}\kern-\tmpa#1%
}
\begin{document}
%\huge
%\tiny
Tac\=e, M\=arc\=o, \=unus, f\=\i li\=\i?
Tac\shortmacron e, M\shortmacron arc\shortmacron o, \shortmacron unus, f\shortmacron\i li\shortmacron\i?
Tac\smartmacron e, M\smartmacron arc\smartmacron o, \smartmacron unus, f\smartmacron\i li\smartmacron\i?
Tac\supersmartmacron e, M\supersmartmacron arc\supersmartmacron o, \supersmartmacron unus, f\supersmartmacron\i li\supersmartmacron\i?
\=a \shortmacron a
\=a \smartmacron a
\=a \supersmartmacron a\quad
\=e \supersmartmacron e\quad
\=i \supersmartmacron i\quad
\=\i \supersmartmacron \i\quad
\=o \supersmartmacron o\quad
\=u \supersmartmacron u\quad
\supersmartmacron a\quad
\supersmartmacron e\quad
\supersmartmacron i\quad
\supersmartmacron \i\quad
\supersmartmacron o\quad
\supersmartmacron u\quad
\end{document}
要使用智能版本的快捷方式,请调用
\let\=\supersmartmacron
在你的序言中。
答案2
Tobi 的答案对于直立字体的小写字母非常有效。我发现自己在斜体字体的大写字母上添加了长音符,因此我对其进行了调整,使其默认为字母的高度并应用了倾斜校正:
% \withoutpt as in the public domain file `samplepdf.tex'
{\catcode`\p=12 \catcode`\t=12 \gdef\WITHOUTPT#1pt{#1}}
\def\withoutpt#1{\expandafter\WITHOUTPT#1} % returns float-like string
% New dimension to deal with slanted fonts
\newlength\macronitalcorr
% Let's name some of Tobi's parameters
\newlength\macrongap
\newlength\macronthickness
\setlength{\macrongap}{0.23ex}%
\setlength{\macronthickness}{0.035em}% thickness
\newcommand{\macronscale}{0.6} % Fraction of letter covered
% I have too many parameters--I can't remember what \tmpa means!
\newlength\macronletterwidth % \tmpa
\newlength\macronadjustment % \tmpb
\newlength\macronheight % \tmpc
\newcommand{\superdupersmartmacron}[1]{{%
% Extra brackets so commands will automatically reset
\setlength{\macronadjustment}{0em}% x-shift
\def\macroninputletter{#1}%
\IfStrEqCase{#1}{%
{a} {\setlength{\macronadjustment}{-0.04em}}%
{e} {\setlength{\macronadjustment}{-0.01em}}%
{i} {\setlength{\macronadjustment}{-0.045em}%
\def\macronscale{0.95}% Wider macron over i
\def\macroninputletter{\i}}% % Automatically use \i for i
{I} {\def\macronscale{0.95}}% Wider macron over I
{\i}{\setlength{\macronadjustment}{-0.045em}%
\def\macronscale{0.95}}% Wider macron over i
{o} {\setlength{\macronadjustment}{-0.01em}}%
{u} {\setlength{\macronadjustment}{-0.04em}}%
}
\settoheight{\macronheight}{\macroninputletter}%
\addtolength{\macronheight}{\macrongap}%
%
% If the font slants, how much do we move the macron?
\macronitalcorr = \withoutpt\the\fontdimen 1 \the\font \macronheight
%
\settowidth{\macronletterwidth}{\macroninputletter}% width of letter
\makebox[\macronletterwidth][c]{%
\kern\macronadjustment%
\kern \macronitalcorr
\rule[\macronheight]{\macronscale\macronletterwidth}
{\macronthickness}%
\kern -\macronitalcorr%
}\kern-\macronletterwidth\macroninputletter%
}}
(还有一些其他花哨的东西——我希望马克龙能取代我s 变得更宽并自动替换i
为\i
。)