我正在尝试在每一页的背景中获取基线网格。我使用的是 XeTeX 的纯文本格式。这是我尝试过的方法:
\baselineskip=13pt
\topskip=0pt \parskip=0pt
\newbox\gridbox
\setbox\gridbox\line{%
\special{color push rgb .8 .8 1}%
\vrule height\baselineskip width0pt \hrulefill%
\special{color pop}}
\def\grid{\vbox to0pt{%
\vtop to\vsize{\leaders\copy\gridbox\vfil}}}
现在,如果我想在单个页面上有一个网格,只需调用 ,上面的方法就可以正常工作\grid
。但是,我希望它出现在每个页面上,因此我尝试重新定义 plain \pagebody
:
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \grid\pagecontents}}
但即使我已经消除了所有垂直拉伸/收缩能力,网格仍然会在各个页面之间漂移。
我究竟做错了什么?
更新
最后我设法弄清楚了导致实际文档与最小文档中出现奇怪行为的原因:是\lineskiplimit=-\maxdimen
。当然没人能猜到。我不知道它为什么会影响任何事情;据我了解,它的唯一功能是找出要使用哪一个,\baselineskip
或\lineskip
,并且由于我将它们都设置为相同,所以我拥有了\lineskiplimit
它原来的状态。但它似乎还做了其他事情(\displ@y
例如,我已经将其从宏中删除了)。
答案1
需要进行一些更正(您忘记了\topskip
)
\newbox\gridbox
\setbox\gridbox\line{%
\special{color push rgb .8 .8 1}%
\vrule height\baselineskip width0pt \hrulefill
\special{color pop}}
\def\grid{\vtop to0pt{\hrule height0pt\kern-\dimexpr\baselineskip-\topskip\relax
\vbox to\dimexpr\vsize+2pt\relax{\leaders\copy\gridbox\vfil}\vss}}
\def\pagebody{\vbox to\vsize{\boxmaxdepth=\maxdepth \grid\pagecontents}}
\parskip=0pt \vsize=\dimexpr\topskip+44\baselineskip\relax % 45 lines per page
\def\1{As any dedicated reader can clearly see, the Ideal of
practical reason is a representation of, as far as I know, the things
in themselves; as I have shown elsewhere, the phenomena should only be
used as a canon for our understanding. The paralogisms of practical
reason are what first give rise to the architectonic of practical
reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the
Ideal of practical reason, yet the manifold depends on the phenomena.
Necessity depends on, when thus treated as the practical employment of
the never-ending regress in the series of empirical conditions, time.
Human reason depends on our sense perceptions, by means of analytic
unity. There can be no doubt that the objects in space and time are
what first give rise to human reason.
Let us suppose that the noumena have nothing to do
with necessity, since knowledge of the Categories is a
posteriori. Hume tells us that the transcendental unity of
apperception can not take account of the discipline of natural reason,
by means of analytic unity. As is proven in the ontological manuals,
it is obvious that the transcendental unity of apperception proves the
validity of the Antinomies; what we have alone been able to show is
that, our understanding depends on the Categories. It remains a
mystery why the Ideal stands in need of reason. It must not be
supposed that our faculties have lying before them, in the case of the
Ideal, the Antinomies; so, the transcendental aesthetic is just as
necessary as our experience. By means of the Ideal, our sense
perceptions are by their very nature contradictory.
}
\1\1\1\1\1\1\1\1\1
\bye
编辑
对此的不同定义\grid
更好地说明了发生了什么:
\def\grid{%
\vtop to 0pt{
\hrule height 0pt % set the reference point
\special{color push rgb .8 .8 1}
\vbox to \vsize{
\vskip\topskip\vskip-0.4pt % backup because of the first rule
\hrule
\cleaders\vbox to\baselineskip{\vfill\hrule width \hsize}\vfill
}
\special{color pop}
\vss % we want to have zero depth
}%
}
答案2
该eso-pic
软件包允许您向每个页面添加材料。使用 TikZ,您可以绘制漂亮的背景网格。
\documentclass{article}
\usepackage{tikz}
\usepackage{eso-pic}
\AddToShipoutPicture{%
\begin{tikzpicture}[overlay,remember picture]
\draw[thick,red]
(current page.north east)
rectangle (current page.south west);
\draw[red!30!white,thin]
(current page.south west) grid[step=2mm]
(current page.north east);
\draw[red!30!white,dotted]
(current page.south west) grid[step=1cm]
(current page.north east);
\end{tikzpicture}%
}
\begin{document}
Hello world.
\clearpage
Hello moon.
\end{document}