GeneralA page with border

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
drpartha
Posts: 43
Joined: Wed Dec 02, 2009 1:41 am

A page with border

Post by drpartha »

Maybe this question is answered somewhere in this forum. If so, please excuse me and give me the place I should see.

My question is "how do I add a border (frame ?) to an entire page ?" The page may contain paragraphs, images, maths expressions, and even page numbering. I want just one or a specific number of pages to have a border all around.
What is the easiest/least cumbersome way to achieve this ? Maybe I can tweak it using \fbox{xxxxx}. Any simple example will be greatly helpful to me.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

A page with border

Post by Stefan Kottwitz »

Here is an example from the LaTeX Cookbook, showing how to use TikZ for this:

Code: Select all

\documentclass{article}
\usepackage{blindtext}
\usepackage{background}
\usetikzlibrary{calc}
\backgroundsetup{angle = 0, scale = 1, vshift = -2ex,
  contents = {\tikz[overlay, remember picture]
    \draw [rounded corners = 20pt, line width = 1pt,
           color = blue, fill = yellow!20, double = blue!10]
           ($(current page.north west)+(1cm,-1cm)$)
           rectangle ($(current page.south east)+(-1,1)$);}}
\pagestyle{empty}
\begin{document}
\Blinddocument
\end{document}
Stefan
LaTeX.org admin
User avatar
drpartha
Posts: 43
Joined: Wed Dec 02, 2009 1:41 am

A page with border

Post by drpartha »

Thanks for the prompt clue. I know TikZ is a complex animal to tame and ride. As expected, my first attempt failed to get
me what I wanted (see attachment border11.png). Guess I will have to struggle harder. I do not give up so easily. I will
update this forum when I reach somewhere closer to my goal.

Thanks anyway,

partha
Attachments
border11.png
border11.png (45.78 KiB) Viewed 14300 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

A page with border

Post by Stefan Kottwitz »

You could also post the code that you try as a compilable example like I did. We may see what the issue is with the code.

Stefan
LaTeX.org admin
User avatar
drpartha
Posts: 43
Joined: Wed Dec 02, 2009 1:41 am

A page with border

Post by drpartha »

I tried the code exactly as you gave it, just to see what it gives:
\documentclass{article}
\usepackage{blindtext}
\usepackage{background}
\usetikzlibrary{calc}
\backgroundsetup{angle = 0, scale = 1, vshift = -2ex,
contents = {\tikz[overlay, remember picture]
\draw [rounded corners = 20pt, line width = 1pt,
color = blue, fill = yellow!20, double = blue!10]
($(current page.north west)+(1cm,-1cm)$)
rectangle ($(current page.south east)+(-1,1)$);}}
\pagestyle{empty}
\begin{document}
\Blinddocument
\end{document}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10319
Joined: Mon Mar 10, 2008 9:44 pm

A page with border

Post by Stefan Kottwitz »

Click the button "Run LaTeX here" to see what my code does.

Also, if you post code, please format it as code as I did. Then it can be compiled here in the forum by the simple button click.

Finally, run the code two times. If something is placed in the backround, like here, a first LaTeX run calculates page coordinates, the second LaTeX run places it correctly based in the coordinates (from the .aux file).

Stefan
LaTeX.org admin
Post Reply