[Tex/LaTex] How to draw a simple 1mm thick page frame

framedmdframedtikz-pgf

I'm trying to make a simple one-line 1mm thick page frame. Left line of that frame should be 2.5cm from edge and all other lines 0.5cm. Document includes tikz drawing, and text.

The problem is that I'm failing to make any frame that is not sticked to the content or drawn by dimensions mentioned above.

I think that this could be made by using packages like frame, or mdframed, but since I've just recently started using LaTeX, I find them a bit difficult to comprehend.

Best Answer

Since you're already using tikz here's an example which makes use of overlays from that package. (See page 200 in the manual for more details). You do need to run this through LaTeX twice to get the placement to be correct.

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\begin{document}
\lipsum[1-20]

\begin{tikzpicture}[remember picture, overlay]
    \node (A) [xshift=2.5cm,yshift=0.5cm] at (current page.south west) {};
    \node (B) [xshift=2.5cm,yshift=-0.5cm] at (current page.north west) {};
    \node (C) [xshift=-0.5cm,yshift=-0.5cm] at (current page.north east) {};
    \node (D) [xshift=-0.5cm,yshift=0.5cm] at (current page.south east) {};

    \coordinate (cA) at (A) ;
    \coordinate (cB) at (B);
    \coordinate (cC) at (C);
    \coordinate (cD) at (D) ;


    \draw[line width=1mm] (cA) -- (cB) -- (cC) -- (cD) -- cycle;
\end{tikzpicture}
\end{document}

You could place the tikzpicture in a command \myborderedpage and then call it on the pages where you want the border:

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}

\newcommand{\myborderedpage}{%
    \begin{tikzpicture}[remember picture, overlay]
    \node (A) [xshift=2.5cm,yshift=0.5cm] at (current page.south west) {};
    \node (B) [xshift=2.5cm,yshift=-0.5cm] at (current page.north west) {};
    \node (C) [xshift=-0.5cm,yshift=-0.5cm] at (current page.north east) {};
    \node (D) [xshift=-0.5cm,yshift=0.5cm] at (current page.south east) {};

    \coordinate (cA) at (A) ;
    \coordinate (cB) at (B);
    \coordinate (cC) at (C);
    \coordinate (cD) at (D) ;


    \draw[line width=1mm] (cA) -- (cB) -- (cC) -- (cD) -- cycle;
    \end{tikzpicture}}

\begin{document}
\lipsum[1-20]

\myborderedpage

\lipsum[21-40]

\myborderedpage

\end{document}

If you're willing to load another tikz library, the following code is a bit simpler and less convoluted than the above examples:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}

\newcommand{\myborderedpage}{%
    \begin{tikzpicture}[remember picture, overlay]
        \draw [line width=1mm]
            ($ (current page.south west) + (2.5cm,0.5cm) $)
            rectangle
            ($ (current page.north east) + (-0.5cm, -0.5cm)$);
    \end{tikzpicture}}

\begin{document}
\lipsum[1-20]

\myborderedpage

\lipsum[21-40]

\myborderedpage

\end{document}