我怎样才能修补 \hrule 以打印 \hrule 三次?

我怎样才能修补 \hrule 以打印 \hrule 三次?

我想要实现的是,a 中的每条第二条线fonttable都比其他线更粗。我通过更新负责输出的命令实现了这一点:

\documentclass{article}

\usepackage{fonttable}

%Adjust fonttable output, so that each odd/even group becomes better visible through thicker lines
\makeatletter

%Adjust command for each group of 16 characters
\renewcommand{\f@tmorechart}{\cr\noalign{\hrule\hrule\hrule\penalty5000}
\f@tchartline \f@toddline \f@tm=\1 \advance\f@tm 1 \xdef\1{\the\f@tm}
\f@tchartline \f@tevenline}

%Adjust command for the end of the chart
\renewcommand{\f@tendchart}{\cr\noalign{\hrule\hrule\hrule}
\raise11.5pt\null&&&\f@thex 8&&\f@thex 9&&\f@thex A&&\f@thex B&
&\f@thex C&&\f@thex D&&\f@thex E&&\f@thex F&\cr
\egroup$$\par}
\makeatother

\begin{document}
\xfonttable{U}{pzd}{m}{n}
\end{document}

但是,我没有在文档中放入那么多代码,而是想到只需修补宏,\hrule让它在被调用时打印自身三次,因此尝试:

\let\OldHrule\hrule
\renewcommand{\hrule}{\OldHrule\OldHrule\OldHrule}

但我现在收到一个错误:

! Leaders not followed by proper glue.
<to be read again>
                   \OldHrule
l.23 \xfonttable{U}{pzd}{m}{n}

这里的问题是什么?有没有一种巧妙的方法来实现我想要的?

答案1

这个答案并没有解释为什么会出现这个错误,但它提出了一种解决方法。

修补\hrule(可能使用\let\OldHrule\hrule \renewcommand{\hrule}{\OldHrule height 2pt})将使全部 \hrules更厚,这可能不是您想要的。

但你至少可以使用\patchcmd(我在评论中采纳了@David Carlisle 的建议)来减少代码:

\documentclass{article}

\usepackage{fonttable}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\f@tmorechart}{\hrule}{\hrule height 1pt}{}{}
\patchcmd{\f@tendchart}{\hrule}{\hrule height 1pt}{}{}
\makeatother

\begin{document}
\xfonttable{U}{pzd}{m}{n}
\end{document}

在此处输入图片描述

相关内容