LaTeX:如何在每一页上制作整页垂直线?

发布于 2024-09-04 21:16:29 字数 177 浏览 5 评论 0 原文

我正在使用 LaTeX,我希望沿着页面左侧、上边距到下边距、距离页面左边缘 0.5 英寸有垂直线。我希望每个页面上都有这个,所以我认为这意味着它必须以某种方式绑定到页眉或页脚?

我完全没有取得任何进展,因此我需要帮助(1)制定完整的规则本身以及(2)使其在文档的每一页上自动发生。

有人可以告诉我该怎么做吗?

I'm using LaTeX and I would like to have vertical rule along left side of page, topmargin to bottommargin, 0.5in from the left edge of the page. I want this on every page, so I assume that means it must somehow be tied to the header or the footer?

I've made no progress at all, so I need help with (1) making the full-length rule itself and (2) making it happen automatically on every page of the document.

Can someone tell me how to do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

千秋岁 2024-09-11 21:16:29

我在 Latex 社区论坛上得到了我的问题的有效答案:http://www.latex-community.org/forum/viewtopic.php?f=5&t=9072&p=34877#p34877

我得到的答案使用“背景” ' 包和这段代码:

\documentclass{article}
\usepackage{background}
\usepackage{lipsum}% just to generate filler text for the example

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{\rule{.4pt}{\paperheight}}
\SetBgHshift{-9cm}

\begin{document}

\lipsum[1-90]

\end{document}

效果很好,很容易调整,将一个 vrule 放在左边距区域,一个放在右边距区域。

I got a working answer to my question on the Latex Community forum: http://www.latex-community.org/forum/viewtopic.php?f=5&t=9072&p=34877#p34877

The answer I got uses the 'Background' package and this code:

\documentclass{article}
\usepackage{background}
\usepackage{lipsum}% just to generate filler text for the example

\SetBgScale{1}
\SetBgAngle{0}
\SetBgColor{black}
\SetBgContents{\rule{.4pt}{\paperheight}}
\SetBgHshift{-9cm}

\begin{document}

\lipsum[1-90]

\end{document}

Works great and was easy to adjust to put one vrule in left margin area and one in the right margin area.

初见终念 2024-09-11 21:16:29

可能有一个 LaTeX 包可以为你做到这一点,但我更像是一个 TeX 人,所以我尝试提出一个 TeX 解决方案(将纯 TeX 与 LaTeX 混合并不总是最好的主意,但我想我有它在职的)。

试试这个。框 255 是框寄存器,TeX 在输出页面之前将页面内容放入其中。我所做的是采用现有的输出例程,并将其更改为插入框 255:一组 0 高度、0 宽度无限收缩但溢出的框,其中包含页面高度 0.4 的规则pt 厚,运气好的话,距左侧半英寸。然后将框255的现有内容添加到该规则之后。然后我调用前面的输出例程,该例程输出页面(现在包括规则)以及页眉和页脚。

\newtoks\oldoutput
\oldoutput=\expandafter{\the\output}%
\output{%
    \setbox255\vbox to 0pt{%
        \hbox to 0pt{%
            \vsize\ht255%
            \vbox to \ht255{%
                \vss
                \hbox to -0.5in{%
                    \hss
                    \vrule height \ht255 width 0.4pt%
                }%
            }\hss
        }\vss
        \box255%
    }%
    \the\oldoutput
}%

将其放在 \begin{document} 命令之前。这可能无法完全解决您的问题,但希望它可以帮助您开始。 这里是一个学习 TeX 原语和内置内容的绝佳页面。

There could be a LaTeX package to do this for you, but I'm more of a TeX person, so I tried to come up with a TeX solution (not always the best idea to mix plain TeX with LaTeX but I think I have it working).

Try this. Box 255 is the box register that TeX places the page contents into before the page is output. What I've done is taken the existing output routine, and changed it to insert into box 255: a 0-height, 0-width infinitely shrinkable-but-overflowing set of boxes containing a rule that is the height of the page, 0.4pt thick and with any luck, half an inch away into the left. The existing contents of box 255 is then added after this rule. Then I call the previous output routine which outputs the page (which now includes a rule), and also the headers and footers.

\newtoks\oldoutput
\oldoutput=\expandafter{\the\output}%
\output{%
    \setbox255\vbox to 0pt{%
        \hbox to 0pt{%
            \vsize\ht255%
            \vbox to \ht255{%
                \vss
                \hbox to -0.5in{%
                    \hss
                    \vrule height \ht255 width 0.4pt%
                }%
            }\hss
        }\vss
        \box255%
    }%
    \the\oldoutput
}%

Put it before your \begin{document} command. This might not solve your problem completely, but hopefully it should get you started. Here's a great page for learning about TeX primitives and built-in things.

旧瑾黎汐 2024-09-11 21:16:29

看看 eso-pic包。从记忆中,您想要的看起来像这样:

\AddToShipoutPicture{%
    \setlength\unitlength{1in}%
    \AtPageUpperLeft{%
        \put(0.5,\topmargin){\vrule width .5pt height \textheight}%
    }%
}

您的问题不清楚您是否希望该行跨越文本区域或整个纸张高度。根据情况,您必须将 \topmargin\textheight 替换为正确的值,0pt 或您的上边距是什么,或者通过\paperheight。如果您尚未使用geometry 包来了解如何控制这些尺寸,请参阅该包。

Have a look at the eso-pic package. From memory, what you want would look like this:

\AddToShipoutPicture{%
    \setlength\unitlength{1in}%
    \AtPageUpperLeft{%
        \put(0.5,\topmargin){\vrule width .5pt height \textheight}%
    }%
}

It's not clear in your question if you want the line to span the text area or the whole paper height. Depending on the case, you have to replace \topmargin and \textheight by the correct values, either 0pt or whatever your top margin is, or by \paperheight. See the geometry package if you don't already use it for how to control those dimensions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文