如果没有 \noindent,\rlap 和 \llap 似乎每次都会向下移动 \baselineskip。这是故意的吗?
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\color{red}
\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}
\color{blue}
\noindent\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}
\color{green}
\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}
\color{black}
\noindent\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}
\end{document}
答案1
和\rlap
都是\llap
根据\hbox
\def\rlap#1{\hb@xt@\z@{#1\hss}}
\def\llap#1{\hb@xt@\z@{\hss#1}}
在哪里
\def\hb@xt@{\hbox to}
但是,\hbox
不能使用 来开始一个段落。您需要使用\noindent
或 之类的命令明确切换到水平模式\leavevmode
。(有关更多详细信息,请参阅 TeX by Topic 的第 16.3 节。)
这里的 MWE 行为可能更像您预期的那样:
\documentclass{article}
\usepackage{xcolor}
\newcommand\aelap[1]{\makebox[0pt][r]{#1}}
\begin{document}
\color{red}
\leavevmode\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}
\color{blue}
\noindent\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}\rlap{\rule{.25in}{1ex}}
\color{green}
\leavevmode\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}
\color{black}
\noindent\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}\llap{\rule{.25in}{1ex}}
\end{document}