对于 'wipet' 建议的纯文本边距注释解决方案这里,似乎所有前面的行,包括边注所在的行,都被向下拉了一段长度(可能是支撑的深度)。
此屏幕截图显示了我编译后的文档的样子(查看前三行如何向下移动到以下几行):
以下是我的完整示例,我将这个注释放在 3 个新页面上的不同设置中。运行此命令的命令是>>lualatex marginnote.tex
。您也可以取消注释声明 package lua-visual-debug 的行以添加调试标记。
% marginnote.tex
\documentclass[notitlepage,letterpaper]{article}
% NOTE: Uncomment the following line, and run with lualatex if you want to visualize debug markers
%\usepackage{lua-visual-debug}
\usepackage{geometry}
\usepackage{fontspec}
\usepackage{blindtext}
\geometry{left=2in,right=2in,top=1in,bottom=1in}
\setmainfont{Verdana}
% wipet's original plain tex margin note solution::
% NOTE: Commented this as using \mnotefont gives me error (I tried with lualatex)
%\let\mnotefont=\tenit
% NOTE: Also increased the horizontal kern to 3em, for some reason 1em makes margin note
% collide with the main contents
\def\mnote#1{\strut\vadjust{\kern-\dp\strutbox\mnoteA{#1}\kern\dp\strutbox}}
\def\mnoteA#1{\smash{\llap{\hbox{\vtop{\mnoteB#1}\kern3em}}}}
\def\mnoteB{\hsize=1.7in \parindent=0pt \leftskip=0pt plus1fill}% \mnotefont}
% NOTE: Commented as doesn't seem relevant as I am using package geometry
%\hoffset=1.5in \advance\hsize by-\hoffset
\begin{document}
\thispagestyle{empty}
\newcommand{\mytesttext}{This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world.\mnote{This is a great world. This is a great world. This is a great world. This is a great world.} This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world. This is a great world.}
\mytesttext
\newpage
\thispagestyle{empty}
\begin{minipage}[t][1cm][t]{\linewidth}
\mytesttext
\end{minipage}
\newpage
\thispagestyle{empty}
\newbox\myoddvbox
\setbox\myoddvbox=\vbox{{\hsize=\textwidth \mytesttext \endgraf}}%
\begin{minipage}[t][1cm][t]{\linewidth}
\box\myoddvbox
\end{minipage}
\end{document}
答案1
问题在于你使用了 LaTeX,而该宏是为纯 TeX 设计的。它在纯 TeX 中运行没有问题。
这是 LaTeX 对原始纯 TeX 宏定义不同的几种情况之一。宏\smash
在纯 TeX 中保持垂直模式,但在 LaTeX 中打开水平模式。为什么?我不知道。请参阅 中的第 5912 行latex.ltx
:
\def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \leavevmode@ifvmode\box\z@}
以及第 1040 行plain.tex
:
\def\finsm@sh{\ht\z@\z@ \dp\z@\z@ \box\z@}
您可以看到差异。
很明显我的宏:
\def\mnote#1{\strut\vadjust{\kern-\dp\strutbox\mnoteA{#1}\kern\dp\strutbox}}
\def\mnoteA#1{\smash{\llap{\hbox{\vtop{\mnoteB#1}\kern3em}}}}
在纯 TeX 中以垂直模式创建\kern\dp\strutbox
(这是正确的),但在 LaTeX 中以水平模式创建\kern\dp\strutbox
(这是不正确的)。
如果我们不能依赖我们的宏仅在纯 TeX 中使用这一事实(这是推荐的),那么我们就不能使用类似的宏,\smash
而必须仅使用原语来代替这样的宏:
\def\mnote#1{\strut\vadjust{\kern-\dp\strutbox\mnoteA{#1}\kern\dp\strutbox}}
\def\mnoteA#1{\setbox0=\hbox to0pt{\hss\hbox{\vtop{\mnoteB#1}\kern3em}}%
\ht0=0pt \dp0=0pt \box0 }