LaTeX forum ⇒ GeneralA page with border

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

A page with border

Postby drpartha » Sat Mar 11, 2023 8:41 am

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 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
User avatar
Stefan Kottwitz
Site Admin
Posts: 9947
Joined: Mon Mar 10, 2008 9:44 pm

A page with border

Postby Stefan Kottwitz » Sat Mar 11, 2023 9:18 am

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

\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: 34
Joined: Wed Dec 02, 2009 1:41 am

A page with border

Postby drpartha » Sat Mar 11, 2023 9:59 am

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 141 times

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

A page with border

Postby Stefan Kottwitz » Sat Mar 11, 2023 11:20 am

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: 34
Joined: Wed Dec 02, 2009 1:41 am

A page with border

Postby drpartha » Tue Mar 14, 2023 6:43 am

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: 9947
Joined: Mon Mar 10, 2008 9:44 pm

A page with border

Postby Stefan Kottwitz » Tue Mar 14, 2023 9:42 am

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


Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests