梅威瑟:
\documentclass[a4paper]{article}
\usepackage[margin=30mm]{geometry}
\usepackage{xcolor}
\begin{document}
\noindent this is good that is food this is good that is food this is good that
is food this is good that is food\linebreak\kern-2em\color{red}\relax this is
good that is food \kern-2em\color{blue}\relax this is good that is food this is
good that is food this is good that is food
\end{document}
第二个\kern
按预期工作,但第一个不工作。这是因为文本被其左边界阻挡了吗?有没有办法让它\kern
在之后工作\linebreak
?
答案1
紧排(像胶水一样)是可丢弃因此它们在换行符处被删除(出于同样的原因,它们\hspace
会被删除,但是 latex 提供了\hspace*
因此,您可以使用\hspace*{-2em}
,或者如果您因为某种原因确实想要使用 kern,那么\linebreak\hbox{}\kern-2em
将在 kern 之前放置一个不可丢弃的框,以防止它被丢弃。
\documentclass[a4paper]{article}
\usepackage[margin=30mm]{geometry}
\usepackage{xcolor}
\begin{document}
\noindent this is good that is food this is good that is food this is good that
is food this is good that is food\linebreak\kern-2em\color{red}\relax this is
good that is food \kern-2em\color{blue}\relax this is good that is food this is
good that is food this is good that is food
\noindent this is good that is food this is good that is food this is good that
is food this is good that is food\linebreak\hspace*{-2em}\color{red}\relax this is
good that is food \hspace*{-2em}\color{blue}\relax this is good that is food this is
good that is food this is good that is food
\noindent this is good that is food this is good that is food this is good that
is food this is good that is food\linebreak\hbox{}\kern-2em\color{red}\relax this is
good that is food \hbox{}\kern-2em\color{blue}\relax this is good that is food this is
good that is food this is good that is food
\end{document}