\hbox_overlap_right:n{} 與 \makebox[0pt][l]{}

\hbox_overlap_right:n{} 與 \makebox[0pt][l]{}

據我了解,我偶然發現了該expl3命令的一些意外行為\hbox_overlap_right:n。我期望下面的所有範例都會產生相同的結果,即框架框與黃色框位於相同的位置。但只有\makebox範例才能產生預期的結果。這些expl3範例甚至在黃色框和框架框之間插入換行符。出了什麼問題?

\documentclass{article}
\usepackage{color}
\usepackage{expl3}

\begin{document}
\ExplSyntaxOn
%doesn't work
\hbox_overlap_right:n{\color{yellow}\rule{1in}{0.5in}}\frame{\phantom{\rule{1in}{0.5in}}}
\par
%doesn't work either
\hbox_to_zero:n{\color{yellow}\rule{1in}{0.5in}\hss}\frame{\phantom{\rule{1in}{0.5in}}}
\par
%LaTeX2e working as expected
\makebox[0pt][l]{\color{yellow}\rule{1in}{0.5in}}\frame{\phantom{\rule{1in}{0.5in}}}
\ExplSyntaxOff
\end{document}

在此輸入影像描述

答案1

此功能\hbox_overlap_right:n與 Plain TeX 相同\rlap(除了\protected),而\hbox_to_zero:n與 相同\hbox to 0pt

> texdef -t latex -p expl3 'hbox_overlap_right:n'

\hbox_overlap_right:n:
\protected\long macro:#1->\hbox_to_zero:n {#1\tex_hss:D }

> texdef -t latex -p expl3 'hbox_to_zero:n'

\hbox_to_zero:n:
\protected\long macro:#1->\tex_hbox:D to\c_zero_dim {#1}

> texdef -t latex frame

\frame:
\long macro:#1->\leavevmode \hbox {\hskip -\@wholewidth \vbox {\vskip -\@wholewidth \hrule \@height \@wholewidth \hbox {\vrule \@width \@wholewidth #1\vrule \@width \@wholewidth }\hrule \@height \@wholewidth \vskip -\@wholewidth }\hskip -\@wholewidth }

由於圖元\hbox沒有啟動水平模式,因此 while\frame\makeboxdo 得到的結果是正常的。

添加\leavevmode之前\hbox_overlap_right:n

相關內容