3

I would like to avoid TikZ or another package. I would like the frame surrounds the page with a rule on all sides and I would like to have a page number below the frame in the middle. I have some difficulties to understand how to use \output and shipout

4
  • You mean rules around the text area of the page, do you? Apr 10, 2011 at 21:50
  • yes I would like one or two rules around the text area for every pages Apr 10, 2011 at 21:56
  • Any particular reason why you want to avoid using a package?
    – Aditya
    Apr 11, 2011 at 16:05
  • No I have to make some texts in plain TeX for friends Apr 11, 2011 at 16:12

2 Answers 2

6

Plain TeX solution:

\def\frameit#1#2{%
 \vbox{\hrule
  \hbox{%
    \vrule \kern#2pt
      \vbox{\kern#2pt #1
         \kern#2pt}%
      \kern#2pt\vrule}
\hrule}}

\output={%
   \shipout\vbox{%
    \frameit{\box255}9
      \medskip
      \centerline{Test Framed Page}}
  \advancepageno}

\frameit{1}{1}
\bye

For any chance to understand output routines start from plain TeX and the TeXBook. See also this post, where I posted some links to TUGBoat articles about the OTR.

3
  • thanks I was looking for a solution like this. Thanks for the post my problem is how to use shipout. Apr 10, 2011 at 22:17
  • @Altermundus If you want to hook anything into LaTeX's output routine rather hook at AtBeginDvi, have a look at source2e.
    – yannisl
    Apr 10, 2011 at 22:21
  • 1
    TeX by Topic has a concise explanation of the use of \output, section 28.2. Apr 11, 2011 at 5:46
4

You could draw the rules by yourself inside the header and footer. See e.g. the layout package to learn about the exact offsets you have to use.

Here my try which is pretty accurate:

\documentclass{article}

\usepackage{lipsum}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\pagestyle{fancy}

\lhead{%
    \raisebox{\dimexpr-\headsep-\dp\strutbox\relax}[0pt][0pt]{\rlap{\hbox to \textwidth{\hrulefill}}}%
    \raisebox{\dimexpr-\headsep-\textheight-\dp\strutbox\relax}[0pt][0pt]{\vrule height \textheight}%
}
\rhead{%
    \raisebox{\dimexpr-\headsep-\textheight-\dp\strutbox\relax}[0pt][0pt]{\vrule height \textheight}%
}
\lfoot{%
    \raisebox{\footskip}[0pt][0pt]{\rlap{\hbox to \textwidth{\hrulefill}}}%
}

\begin{document}
\lipsum[1-40]
\end{document}

Result:

Result

1
  • Interesting and more clear to understand for me but I prefer to avoid the use of a package. This solution can be useful ! thanks now I need to understand the code from Yiannis Apr 10, 2011 at 22:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .