add tag
UdiB
I want to print a red page border on the very edge of the pages of my document.

1. Is there any way to achieve it without using `tikz` and `remember picture,overlay`? E.g. `picture` environment or even with `hrule` and `vrule`?

2. I just tried to do it with tikz, but I don't know why the anchors are not set correctly: The red circle is not in the page center and the rectangle (the page border) is not placed on the page corners. MWE:

```
% !TEX TS-program = lualatex
\begin{filecontents}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2024/09/13 My document class]
\renewcommand\normalsize{\fontsize{18pt}{22pt}\selectfont}
\end{filecontents}
\documentclass{myclass}
\synctex=0
\pageheight 13cm          \pagewidth 24cm
\paperheight\pageheight   \paperwidth\pagewidth
\textwidth\pagewidth
\textheight\pageheight
\hoffset=-1in
\voffset=-1in
\headheight=0pt \headsep=0pt \footskip=0pt \topskip=0pt
\topmargin=0pt
\oddsidemargin=0pt

\usepackage{fontspec}
\setmainfont{Arial}
\parindent 0pt
\parskip 10pt

\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[remember picture,overlay]
    \draw [fill=red] (current page.center) circle (3pt);
    \draw [red,very thick](current page.south east) rectangle (current page.north west);
  \end{tikzpicture}
Content goes here.
\end{document}
```
Changing the document class to `article` and recompiling gives correct border. But I want to use my document class defined above.

**Note:** I don't want to use the geometry package!
Top Answer
samcarter
If you would like to avoid tikz, you could draw a frame using picture mode:


```
% !TEX TS-program = latexmk -lualatex %
\begin{filecontents}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2024/09/13 My document class]
\renewcommand\normalsize{\fontsize{18pt}{22pt}\selectfont}
\end{filecontents}
\documentclass{myclass}
\synctex=0
\pageheight 13cm          \pagewidth 24cm
\paperheight\pageheight   \paperwidth\pagewidth
\textwidth\pagewidth
\textheight\pageheight
\hoffset=-1in
\voffset=-1in
\headheight=0pt \headsep=0pt \footskip=0pt \topskip=0pt
\topmargin=0pt
\oddsidemargin=0pt

\usepackage{fontspec}
\setmainfont{Arial}
\parindent 0pt
\parskip 10pt

\usepackage{xcolor}

\AddToHook{shipout/background}{%
  \setlength{\unitlength}{1in}
  \put(\dimexpr-\hoffset+1mm,\dimexpr-\paperheight+\voffset+1mm){\color{red}\framebox(\dimexpr\paperwidth-2mm,\dimexpr\paperheight-2mm){}}%
}
\begin{document}

Content goes here.
\end{document}
```
![document-1.png](/image?hash=5c283bc4e5b57ed9b7675824192f06054c7476e950121f7817a2679bc0920289)
Answer #2
samcarter
Concerning your second question:

You can do it in tikz if you compensate for the `\hoffset` and `\voffset` (don't forget to compile two times)

```
% !TEX TS-program = lualatex
\begin{filecontents}{myclass.cls}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2024/09/13 My document class]
\renewcommand\normalsize{\fontsize{18pt}{22pt}\selectfont}
\end{filecontents}
\documentclass{myclass}
\synctex=0
\pageheight 13cm          \pagewidth 24cm
\paperheight\pageheight   \paperwidth\pagewidth
\textwidth\pagewidth
\textheight\pageheight
\hoffset=-1in
\voffset=-1in
\headheight=0pt \headsep=0pt \footskip=0pt \topskip=0pt
\topmargin=0pt
\oddsidemargin=0pt

\usepackage{fontspec}
\setmainfont{Arial}
\parindent 0pt
\parskip 10pt

\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}[remember picture,overlay,transform canvas={xshift=-\hoffset,yshift=-\voffset}]
    \draw [fill=red] (current page.center) circle (3pt);
    \draw [red,line width=3mm](current page.south east) rectangle (current page.north west);
  \end{tikzpicture}
Content goes here.
\end{document}
```

![document2-1.png](/image?hash=8aede8a216c80e35e9437d40c2e2d73db87ff5f42709f650653e040475d66158)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.