3

I want to make a math exam paper via exam package but with the information of students on the left of the first page. We may deal with this by rotated line. However, it is the table I have to print. By the way, there is some error if I use table enviorment in the minipage enviorment. This is what I supposed to achieve by office. enter image description here

Here is the code without the exam package.

\documentclass{article}
\usepackage{lipsum,tikz}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node [xshift=2cm,yshift=-1.5cm] at (current page.north west) (topleft){};
\node [xshift=2cm,yshift=1.5cm] at (current page.south west) (bottomleft){};
\draw [->] (topleft.south) -- (bottomleft.north);
\end{tikzpicture}

\begin{table}[htbp]
\centering
\caption{mytable}
\begin{tabular}{|c|}
\hline
name\\
\hline
\\
\hline
id\\
\hline
\\
\hline
subject\\
\hline
\\
\hline
\end{tabular}
\end{table}

\lipsum[1-7]

\end{document}
8
  • I would remove the \centering command and and load the caption package for not centring the caption, with \captionsetup{singlelinecheck=false}
    – Bernard
    May 25, 2019 at 9:11
  • I add the caption table and delete \centering command, but the table is still on the right of the vertical line.
    – Brooks
    May 25, 2019 at 9:14
  • Why have you put a \newpage inside a table? What is the line for? May 25, 2019 at 9:14
  • Soooorry, it's a typo.
    – Brooks
    May 25, 2019 at 9:16
  • Can you make a rough drawing of what you want and upload the picture? May 25, 2019 at 9:18

2 Answers 2

1

I'd use standard exam methods, hooking into \lhead: the left header will contain \databox, whose duty is to typeset the data box having zero width and height, but with parameters to place it down the left margin. Then \databox redefines itself to do nothing.

\documentclass{exam}

\usepackage{lipsum}

\newcommand{\databox}{%
  \smash{\makebox[0pt][r]{%
    \begin{tabular}[t]{|c|}
    \multicolumn{1}{c}{} \\[2in] % lower the box
    \hline
    name\\
    \hline
    \\[2\normalbaselineskip]
    \hline
    id\\
    \hline
    \\[1.5\normalbaselineskip]
    \hline
    subject\\
    \hline
    \\[3\normalbaselineskip]
    \hline
    \end{tabular}\quad
  }}%
  \gdef\databox{}%
}

\lhead{\databox}

\begin{document}

\lipsum[1-9]

\end{document}

enter image description here

2
  • how to move the table toward right a little bit but with the text on the right motionless. And I may concern whether the table will cover the text.
    – Brooks
    May 28, 2019 at 6:55
  • @Brooks Change \quad into \hspace{...} until you're satisfied. Tthe argument should be a length; as long as it's positive, the table will stay in the margin.
    – egreg
    May 28, 2019 at 8:27
3

I suggest you set up two minipage environments, a narrow one on the left, a wide one on the right. As long as the contents of the minipages fit within the overall page, they will be centered vertically relative to each other. In the example below, the ratio of minipage widths is set to 3:17; obviously, you're free to choose a different ratio.

Then, in the left-hand minipage, use a single-column tabularx environment. Since it doesn't look like you need to set a \caption, I don't think there's a purpose in employing a table environment.

enter image description here

\documentclass{article}
\usepackage{lipsum,tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
\noindent
\begin{minipage}{0.15\textwidth}
\renewcommand\arraystretch{4} % or some other suitable factor
\begin{tabularx}{\textwidth}{|@{}C@{}|}
\hline
Name\\    \hline
{}\\      \hline
id\\      \hline
{}\\      \hline
subject\\ \hline
{}\\      \hline
\end{tabularx}
\end{minipage}
\quad
\begin{minipage}{\dimexpr0.85\textwidth-1em\relax}
\lipsum[1-3]
\end{minipage}
\end{document}
8
  • thanks for your great answer. there is a new problem, I have to decide where to creat a new page in the right minipage.
    – Brooks
    May 25, 2019 at 10:14
  • @Brooks - Please provide more information about your additional typographic objective.
    – Mico
    May 25, 2019 at 10:31
  • The length of the stuff in the right minipage is due to some math exercise, but different kinds of exercise have different size. I don't know there is how many questions on the first page.
    – Brooks
    May 25, 2019 at 10:41
  • @Brooks - And what would "different sizes" be?
    – Mico
    May 25, 2019 at 10:42
  • 1
    @Brooks - As I was careful to note in my answer, it applied to cases where the text material actually fits on a page.
    – Mico
    May 25, 2019 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .