![水平线无垂直间隙](https://linux22.com/image/327386/%E6%B0%B4%E5%B9%B3%E7%BA%BF%E6%97%A0%E5%9E%82%E7%9B%B4%E9%97%B4%E9%9A%99.png)
答案1
尝试这个
\documentclass{article}
\begin{document}
\noindent
\makebox[0pt][l]{\Large\bfseries John Smith}%%
\rule[-0.5ex]{\columnwidth}{0.4pt}
Hell world, this is my cover letter.
\end{document}
有类似\rlap
和 的命令\\lap
。但我认为\makebox
这很有趣。你可以设置框的宽度和对齐方式左右,或者中心。
\documentclass{article}
\begin{document}
\noindent
\rule[-0.5ex]{\columnwidth}{0.4pt}%%
\hspace*{-\dimexpr\columnwidth/2}%%
\makebox[0pt]{\Large\bfseries John Smith}%%
\hspace*{\dimexpr\columnwidth/2}%%
Hell world, this is my cover letter.
\end{document}
按照这个总体思路,你可以创建如下命令
\documentclass{article}
\newif\ifaeShowAnswers
\newcommand\aeShowAnswer[2]{%%
\rule[-0.5ex]{#1}{0.4pt}%%
\hspace*{-\dimexpr#1/2}%%
\makebox[0pt]{\ifaeShowAnswers#2\fi}%%
\hspace*{\dimexpr#1/2}}
%%\aeShowAnswerstrue
\begin{document}
Lord \aeShowAnswer{1.25in}{Voldemort} is the \aeShowAnswer{1.25in}{Harry Potter}'s archnemesis.
\end{document}
结果是
通过取消注释该行,\aeShowAnswerstrue
结果为