答案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
结果为