我想在我的 Plain TeX 文档中添加 Tufte 样式的边注。(如果有必要的话,我会使用 eplain。)我知道如果我使用 LaTeX,我可以使用 tufte-latex,但作为一个彻底的反对者,我喜欢自己编写这些东西。
我是几乎但是当我调用它时,我当前的宏会将文本放置在相对于当前位置的位置,而不是相对于页边距的位置。在我的 MWE 中,注释被放置在事物的中间。但是,如果您移动调用\sidenote
,旁注可能会更靠近左边距。我怎样才能将旁注文本相对于左边距(或右边距)而不是当前位置重新定位?(我在 MWE 中使用了左边距。)
我真正做我最喜欢的是,我的宏的第一行和它引用的正文的基线是对齐的。我想保留这一点。欢迎对我的宏提出任何其他建议。
梅威瑟:
\input eplain
\leftmargin=2in
\font\sidenotefont= pxi at8.5pt
\long\def\sidenote#1{\llap{\smash{\vtop{%
\parindent=0pt\hsize=1.5in\rightskip=.87in\parfillskip=0pt\leftskip=-1in plus1fil%
\baselineskip=10pt\sidenotefont #1}}}}
When we are working at a difficult task and strive after a good thing, we are
fighting a righteous battle, the direct reward of which is that we are kept from
\sidenote{This note has been brought to you by the letter pi and
the number e. Please make a note of it. The reason for its existence is the
great lengths I went to do things.}much evil. As we advance in life it becomes more and more difficult, but in
fighting the difficulties the inmost strength of the heart is developed. Indeed
life is a have to defend and protect ourselves, and with a cheerful and brace
spirit we must battle; we plan and calculate in order to make progress.
\bye
答案1
如果线条没有不寻常的深度,这可能是一个起点:
\input eplain
\leftmargin=2in
\font\mainfont=pxr at 10pt
\font\sidenotefont=pxi at 8.5pt
\long\def\sidenote#1{%
\vadjust{\llap{\smash{\vtop{%
\parindent=0pt
\hsize=1.7in
\parfillskip=0pt
\leftskip=0pt plus1fil
\baselineskip=10pt\sidenotefont\vglue-\ht\strutbox #1}}\kern1em}}}
\mainfont
When we are working at a difficult task and strive after a good thing, we
are fighting a righteous battle, the direct reward of which is that we are
kept from \sidenote{This note has been brought to you by the letter pi and
the number e. Please make a note of it. The reason for its existence is the
great lengths I went to do things.}much evil. As we advance in life it becomes
more and more difficult, but in fighting the difficulties the inmost strength
of the heart is developed. Indeed life is a have to defend and protect ourselves,
and with a cheerful and brace spirit we must battle; we plan and calculate in
order to make progress.
\bye
关键是\vadjust
将材料添加到封闭的垂直列表中。
答案2
在阅读了 TeXBook (14.28) 中的相应练习后,这是我的\strut
基于 的解决方案。感谢 @Mafra 建议练习。
\def\strutdepth{\dp\strutbox}
\def\simplesidenote#1{%
\strut\vadjust{\kern-\strutdepth\lsidenote{#1}}}
\def\lsidenote#1{\vtop to \strutdepth{%
\baselineskip\strutdepth%
\vss\llap{\vtop to 0pt{%
\leftskip=0pt plus1fill \rightskip=8pt%
\parfillskip=0pt \parindent=0pt%
\hsize=1.7in%
\eightpoint\it #1}}\null}}
注意这\eightpoint
只是一个调整字体大小的宏。
答案3
我想指出前面答案中存在的问题并给出更简单的解决方案。
egerg 的答案包括临时修正\vglue-\ht\strutbox
。在他的解决方案中,边注文本的垂直定位取决于段落中行的深度和注释文本中第一行的高度。您可以尝试从示例中的段落第二行中删除所有具有非零降部的字母和字符(即 g、p、逗号等),您会发现边注位置会很糟糕。这个错误是恶意的因为代码\vglue-\ht\strutbox
看起来这样做是有原因的。但事实并非如此。它
\vskip-8.5pt
做同样的工作,并且不会删除边注的意外位置。
EfForEffort 的答案很糟糕,因为\baselineskip
设置为较小的值会导致\vtop
线条没有等距基线:线条以较小的垂直空间 1pt 相互依靠,这是寄存器的默认值\lineskip
。
Knuth 对 TeXbook 中的练习 14.28 的回答(使用宏将星号打印到左边距\marginstar
):
\def\strutdepth{\dp\strutbox}
\def\marginalstar{\strut\vadjust{\kern-\strutdepth\specialstar}}
\def\specialstar{\vtop to \strutdepth{
\baselineskip\strutdepth
\vss\llap{* }\null}}
是太过复杂因为在 中 后面\vtop to\strutdepth
跟着设置,\baselineskip=\strutdepth
后面跟着终止符。14.28 练习的这个解决方案要简单得多:\null
\vtop
\def\marginalstar{\strut\vadjust{\kern-\dp\strutbox\smash{\llap{* }}\kern\dp\strutbox}}
如果您需要在边注中添加更多行:
\let\mnotefont=\tenit
\def\mnote#1{\strut\vadjust{\kern-\dp\strutbox\mnoteA{#1}\kern\dp\strutbox}}
\def\mnoteA#1{\smash{\llap{\hbox{\vtop{\mnoteB#1}\kern1em}}}}
\def\mnoteB{\hsize=1.7in \parindent=0pt \leftskip=0pt plus1fill \mnotefont}
\hoffset=1.5in \advance\hsize by-\hoffset
When we are working at a difficult task and strive after a good thing, we
are fighting a righteous battle, the direct reward of which is that we are
kept from%
\mnote{This note has been brought to you by the letter pi and the number e.
Please make a note of it. The reason for its existence is the great
lengths I went to do things.}
much evil. As we advance in life it becomes more and
more difficult, but in fighting the difficulties the inmost strength of the
heart is developed. Indeed life is a have to defend and protect ourselves,
and with a cheerful and brace spirit we must battle; we plan and calculate
in order to make progress.
\bye
如果您使用 OPmac:
\input opmac
\fixmnotes\left \mnotesize=1.7in \def\mnotehook{\typosize[8/10]\it}
\margins/1 letter (2.5,1,1,1)in
When we are working at a difficult task and strive after a good thing, we
are fighting a righteous battle, the direct reward of which is that we are
kept from%
\mnote{This note has been brought to you by the letter pi and the number e.
Please make a note of it. The reason for its existence is the great
lengths I went to do things.}
much evil. As we advance in life it becomes more and
more difficult, but in fighting the difficulties the inmost strength of the
heart is developed. Indeed life is a have to defend and protect ourselves,
and with a cheerful and brace spirit we must battle; we plan and calculate
in order to make progress.
\bye
答案4
捷克共和国的 Petr Olsak 编写了一个很棒的宏,甚至可能比 eplain 还要好。Olsak 因偏爱 plainTeX 而出名,他编写这个宏是为了向 plainTeX 用户提供 LaTeX 的强大功能。文件的名称 (opmac.tex) 实际上代表哦伊萨克磷莱茵泰克斯苹果玫瑰。
http://petr.olsak.net/opmac-e.html
文档也有英文版。安装后,\input opmac
您只需键入内容\mnote{your text in margin}
,它就会相应地将其放置在奇数页的左边距中,偶数页的右边距中,除非您有理由将它们放在所有页面的同一侧。一切都可以设置,正如您将在文档中了解到的那样。