答案1
更长的分数条
\frac
可以重新定义以给分子和分母添加额外的空间,从而得到更长的分数线,例如:
\documentclass{article}
\let\OrgFrac\frac
\renewcommand*{\frac}[3][\,]{%
\OrgFrac{#1\relax#2#1}{#1\relax#3#1}%
}
\begin{document}
\[
\frac[]{1}{2},
\frac{1}{2},
\frac[\mkern4mu]{1}{2}
\]
\end{document}
分数线的圆线端
如果circle corner style
表示条形的圆线端,则以下示例通过 TikZ 将条形的线端套印为圆线:
\documentclass{article}
\usepackage{tikz}
\makeatletter
\let\OrgFrac\frac
\newcommand*{\roundfrac}[2]{%
\mathpalette{\@roundfrac{#1}{#2}}{}%
}
\newcommand*{\@roundfrac}[4]{%
% #1: numerator
% #2: denominator
% #3: math style
% #4: unused/empty
\begingroup
%\sbox0{$#3#1\m@th$}%
%\sbox2{$\cramped[#3]{#2}\m@th$}%
\edef\BarLineWidth{%
\the\fontdimen8%
\ifx\displaystyle#3\textfont
\else\ifx\textstyle#3\textfont
\else\ifx\scriptstyle#3\scriptfont
\else\scriptscriptfont
\fi\fi\fi
3 %
}%
\sbox0{%
\kern-\nulldelimiterspace
$#3\OrgFrac{#1}{#2}\m@th$%
\kern-\nulldelimiterspace
}%
\sbox2{$#3\vcenter{}$}% math axis
\kern\nulldelimiterspace
\begin{tikzpicture}[
inner sep=0pt,
outer sep=0pt,
baseline=(frac.base),
line cap=round,
line width=\BarLineWidth,
]
\node[anchor=base] (frac) {\copy0};
\draw (frac.west |- 0, \ht2) -- (frac.east |- 0, \ht2);
\end{tikzpicture}%
\kern\nulldelimiterspace
\endgroup
}
\makeatother
\let\frac\roundfrac
\begin{document}
\[
\OrgFrac{1}{2};
\frac{1}{2},
\textstyle\frac{1}{2},
\scriptstyle\frac{1}{2},
\scriptscriptstyle\frac{1}{2}
\]
\end{document}
当然,较长的分数线和圆角线端可以结合起来。这留给读者作为一个简单的练习。