在右边距画一条线

在右边距画一条线

我需要用 LaTeX 准备一份试卷,我必须在试卷的右边距画两条线,并在页面开头写上“请勿在此边距书写”。有没有办法在右边距书写?或者我应该使用长表格?如果我没有发布任何最小示例,我很抱歉,但我完全不知道如何开始!

这些行的示例如下:

在此处输入图片描述

垂直线应该沿着整张纸延伸,并在下一页继续(开头使用相同的标签)。

干杯

答案1

这是 MWV,你可以改进它

\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}

在此处输入图片描述

编辑

要将其包含在每一页上,请使用everypage

\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}
}

在此处输入图片描述

答案2

因为您希望每一页都书写,所以您可以使用eso-pic

\documentclass{exam}
\usepackage[left=.5in, right=2in, marginparwidth=0pt]{geometry}
\usepackage{eso-pic}
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{positioning}

% for testing purpose only:
\usepackage{mwe}
%\usepackage{showframe}

\begin{document}
    \AddToShipoutPictureBG{%
        \AtPageLowerLeft{% 
            \begin{tikzpicture}[overlay,remember picture]
            % angles
            \coordinate (pagene) at (.98\paperwidth,.98\paperheight);
            \draw[line width=4pt] (pagene) -- +(-1,0) -- (pagene) -- +(0,-1);
            \coordinate (pagenw) at (.02\paperwidth,.98\paperheight);
            \draw[line width=4pt] (pagenw) -- +(1,0) -- (pagenw) -- +(0,-1);
            \coordinate (pagese) at (.98\paperwidth,.02\paperheight);
            \draw[line width=4pt] (pagese) -- +(-1,0) -- (pagese) -- +(0,1);
            \coordinate (pagesw) at (.02\paperwidth,.02\paperheight);
            \draw[line width=4pt] (pagesw) -- +(1,0) -- (pagesw) -- +(0,1);
            \end{tikzpicture}}
        \ifthenelse{\value{page}>2}{% if page > 2 add:
        \AtPageLowerLeft{% 
            \begin{tikzpicture}[overlay,remember picture]
            % Writing at the very top
            \node[anchor=north east, align=center,
            font=\small] (W) 
            at (.95\paperwidth,.95\paperheight) 
            {DO NOT \\ WRITE IN\\ THIS \\ MARGIN};
            \node[anchor=north east, 
            font=\bfseries, align=right] 
            at (W.north west) {MARKS};
            % vertical lines
            \draw[thin] (W.north west) -- +(0,-.9\paperheight);
            \draw[thin] (W.north east) -- +(0,-.9\paperheight);
            % horizontal line
            \draw[thin] (W.south west) -- (W.south east);
            \end{tikzpicture}}%
        }{}%
        }

    % your content here 
    \textbf{FORMULAE LIST}

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

    % this is for testing purpose only:
    \blindtext[30]
\end{document}

第 1 页仅角落:

在此处输入图片描述

第 2 页仅角落:

在此处输入图片描述

从第 3 页开始,角落、线条和文字:

在此处输入图片描述

相关内容