1

I'm using the exam class, and I have tables in it's solution environment, but I found that a table extrudes from the frame of the solution environment at the bottom of the page, see the image shot below.

image shot

Also, here is the minimal code to demonstrate this issue, any one can help me to solve this issue? Thanks.

\documentclass[addpoints]{exam}
\usepackage{amsmath}


\begin{document}
\printanswers
\begin{questions}
\question this is the question
\begin{solution}
The DH parameters:

 \begin{tabular}{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

\end{solution}

\question this is the question
\begin{solution}
The DH parameters:

 \begin{tabular}{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

   \[T=T_1T_2T_3=
     \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}
     C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \]

\end{solution}

\question this is the question
\begin{solution}
The DH parameters:

 \begin{tabular}{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

   \[T=T_1T_2T_3=
     \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}
     C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \]

\end{solution}

\end{questions}

\end{document}
0

1 Answer 1

2

By default the tabular is vertically centred so half its size is in the depth which is why it causes problems. (The exam class could catch this but apparently not) so the easiest thing to do is use [b] so that the tabular has height rather than depth, then the table moves to the next page.

I added a \nopagebreak so the previous line stayed with the table and also moved over. In practice, you should probably add \clearpage before the question and move the whole question over.

Not directly related (and I didn't change here) you should not have a blank line before \[ nor consecutive \[\] environments, it would be better to use a multi-line display from amsmath

\documentclass[addpoints]{exam}
\usepackage{amsmath}


\begin{document}
\printanswers
\begin{questions}
\question this is the question
\begin{solution}
The DH parameters:

 \begin{tabular}{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

\end{solution}

\question this is the question
\begin{solution}
The DH parameters:

 \begin{tabular}{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

   \[T=T_1T_2T_3=
     \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}
     C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \]

\end{solution}

\question this is the question

\begin{solution}
The DH parameters:
\nopagebreak

 \begin{tabular}[b]{|c|c|c|c|c|}
  \hline
 Link& $b_i$& $\theta_i$& $a_i$ & $\alpha_i$\\
  \hline
 1 & $b_1$ & $\theta_1$ & $a_1$& 0\\
  \hline
 2 & $b_2$ & $\theta_2$ & $a_2$& 0\\
  \hline
 3 & $b_3$ &0 & 0& 0\\
  \hline
 4& $b_4$ & $\theta_4$ & 0& 0\\
  \hline
 \end{tabular}

 \[T=T_1T_2T_3=
   \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}
   C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
   \]

   \[T=T_1T_2T_3=
     \begin{bmatrix} C_1&-S_1&S_1&0\\S_1&C_1&-C_1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}
     C_2&-S_2&0&a_2C_2\\S_2&C_2&0&a_2S_2\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \begin{bmatrix}  C_3&-S_3&0&a_3C_3\\S_3&C_3&0&a_3S_3\\0&0&1&0\\0&0&0&1\end{bmatrix} \quad
     \]

\end{solution}

\end{questions}

\end{document}
2
  • Add the [b] option to the table solved the issue, I believe the true solution is the solution environment should take care of this issue. About the equation empty line, I just copy and paste the equations to make a minimal sample code, I do use multiply line equations in my original code.
    – ollydbg23
    Apr 16, 2015 at 11:21
  • I noticed that not only the tabular, but also the equation could touch the border of the solution's frame when the solution is crossing the pages. So, I have turn the border off by using the command \unframedsolutions. By reading the document of the exam class, I see it use the \fbox as the solution's frame box.
    – ollydbg23
    Apr 17, 2015 at 0:38

You must log in to answer this question.

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