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
Asked
Active
Viewed 702 times
3
Alain Matthes
- 95,075
-
You mean rules around the text area of the page, do you? – Martin Scharrer Apr 10 '11 at 21:50
-
yes I would like one or two rules around the text area for every pages – Alain Matthes Apr 10 '11 at 21:56
-
Any particular reason why you want to avoid using a package? – Aditya Apr 11 '11 at 16:05
-
No I have to make some texts in plain TeX for friends – Alain Matthes Apr 11 '11 at 16:12
2 Answers
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.
-
thanks I was looking for a solution like this. Thanks for the post my problem is how to use
shipout. – Alain Matthes Apr 10 '11 at 22:17 -
@Altermundus If you want to hook anything into LaTeX's output routine rather hook at
AtBeginDvi, have a look atsource2e. – yannisl Apr 10 '11 at 22:21 -
1TeX by Topic has a concise explanation of the use of
\output, section 28.2. – Charles Stewart Apr 11 '11 at 05: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:

Martin Scharrer
- 262,582
-
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 – Alain Matthes Apr 10 '11 at 22:22