答案1
可以通过测量文本的宽度并从线宽中减去该宽度来计算规则的宽度。
可以根据堆叠的规则绘制线条\vcenter
,将内容围绕数学轴居中。
例子:
\documentclass{article}
\usepackage{color}
\newcommand*{\EndChapter}[1]{%
\par
\noindent
\begingroup
\sbox0{\bfseries\ #1\ }%
\dimen0=.5\dimexpr\linewidth-\wd0\relax
\BlueLines{\dimen0}%
\usebox0%
\BlueLines{\dimen0}%
\endgroup
}
\newcommand*{\BlueLines}[1]{%
$%
\mathsurround=0pt %
\color{blue}%
\vcenter{%
\hrule width#1 height\BlueLinesThickness
\kern\BlueLinesSep
\hrule width#1 height\BlueLinesThickness
\kern\BlueLinesSep
\hrule width#1 height\BlueLinesThickness
\kern\BlueLinesSep
\hrule width#1 height\BlueLinesThickness
\kern\BlueLinesSep
\hrule width#1 height\BlueLinesThickness
}%
$%
}
\newdimen\BlueLinesThickness
\setlength{\BlueLinesThickness}{2pt}
\newdimen\BlueLinesSep
\setlength{\BlueLinesSep}{1.5pt}
\begin{document}
\EndChapter{Problems of Week 1}
\end{document}