右端に線を引く

右端に線を引く

LaTeX で試験用紙を準備する必要があり、用紙の右余白全体に 2 本の線を引いて、ページの先頭に「この余白には書き込まないでください」と書く必要があります。右余白に書き込む方法はありますか? それとも長い表を使うべきでしょうか? 簡単な例を投稿していないと申し訳ないのですが、どのように始めればよいのかまったくわかりません。

行の例は次のとおりです。

ここに画像の説明を入力してください

縦線はシート全体にわたって続き、次のページにも(先頭に同じラベルを付けて)続きます。

乾杯

答え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ページ目以降は、角、線、書き込みです。

ここに画像の説明を入力してください

関連情報