[Tex/LaTex] Drawing a line on the right margin

examtables

I need to prepare an exam paper in LaTeX and I have to draw two lines all across the right margin of the sheet with written at the beginning of the page "DO NOT WRITE IN THIS MARGIN". Is there a way to write in the right margin? Or should I use a long table? I am sorry if I don't post any minimal example, but I have utterly no idea of how to start!

An example of the lines is the following:

enter image description here

the vertical lines are meant to continue all along the sheet, and continue (with the same label at the beginning) in the following page.

Cheers

Best Answer

This is MWV, you can improve it

\documentclass[]{article}

\usepackage{geometry}
\usepackage{tikzpagenodes}
\usepackage{tikz}

\usetikzlibrary{backgrounds}
\geometry{left = 2cm, right = 1cm, marginparwidth = 2cm, includemp}

\begin{document}

\begin{tikzpicture}[remember picture, overlay, black]
  \coordinate (mNE) at (current page marginpar area.east |- current page header area.north);
  \coordinate (mNW) at (current page text area.west |- current page header area.north);

  \coordinate (mSE) at (current page marginpar area.east |- current page footer area.south);
  \coordinate (mSW) at (current page text area.west |- current page footer area.south);

  \begin{scope}[line width = 3pt]
    \draw[] (mNE) ++(0, -1cm) -- (mNE) -- ++(-1cm, 0);
    \draw[] (mNW) ++(0, -1cm) -- (mNW) -- ++(1cm, 0);
    \draw[] (mSE) ++(0, 1cm) -- (mSE) -- ++(-1cm, 0);
    \draw[] (mSW) ++(0, 1cm) -- (mSW) -- ++(1cm, 0);
  \end{scope}

  \draw (current page marginpar area.north east) -- (current page marginpar area.south east);
  \draw (current page marginpar area.north west) -- (current page marginpar area.south west);

  \node[left] at (current page marginpar area.north west) {MARKS};
  \node[right, text width = 2cm] at (current page marginpar area.north west) {DO NOT \\ WRITE IN\\ THIS \\ MARGIN};

\end{tikzpicture}

{\bf FORMULAE LIST} \par

The roots of $ax^2 + bx + c = 0$ are $\displaystyle{x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}}$

\end{document}

enter image description here

EDIT

To include this on every page use the everypage package

\AddEverypageHook{
  \begin{tikzpicture}[remember picture, overlay, black]
    \coordinate (mNE) at (current page marginpar area.east |- current page header area.north);
    \coordinate (mNW) at (current page text area.west |- current page header area.north);       
    \coordinate (mSE) at (current page marginpar area.east |- current page footer area.south);
    \coordinate (mSW) at (current page text area.west |- current page footer area.south);       
    \begin{scope}[line width = 3pt]
      \draw[] (mNE) ++(0, -1cm) -- (mNE) -- ++(-1cm, 0);
      \draw[] (mNW) ++(0, -1cm) -- (mNW) -- ++(1cm, 0);
      \draw[] (mSE) ++(0, 1cm) -- (mSE) -- ++(-1cm, 0);
      \draw[] (mSW) ++(0, 1cm) -- (mSW) -- ++(1cm, 0);
    \end{scope}       
    \draw (current page marginpar area.north east) -- (current page marginpar area.south east);
    \draw (current page marginpar area.north west) -- (current page marginpar area.south west);       
    \node[left] at (current page marginpar area.north west) {MARKS};
    \node[right, text width = 2cm] at (current page marginpar area.north west) {DO NOT \\ WRITE IN\\ THIS \\ MARGIN};
  \end{tikzpicture}
}

enter image description here

Related Question