9

I am trying to put four figures in one page. I have tried using \clearpage, \afterpage{\clearpage} with afterpage package as suggested and worked successfully in many other cases. I have also tried scaling down the image, using h, H, p etc. with figure command. None did work in my case.

Help me please putting these four pictures on a page. My code at present is:

\documentclass[addpoints,11pt]{exam}
\usepackage{graphicx} %to display graphics!
\usepackage{afterpage}
\firstpagefootrule
\begin{document}
\begin{questions}
\question[] True/False questions.
\label{label:a}
    \begin{parts}
        \part[2] True or False.
        An image:
        \begin{figure}[h]
            \centering
            \includegraphics[scale=0.5]{test}
            \caption{Figure of Q.\ref{label:a}}
            \label{label:q1}
        \end{figure}
    \end{parts}

\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:
        \begin{figure}[h]
            \includegraphics[scale=0.5]{test}
            \caption{Figure of Q.2}
            \label{label:q2}
        \end{figure}
    \end{parts}

\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:
        \begin{figure}[h]
            \includegraphics[scale=0.5]{test}
            \caption{Figure of Q.3}
            \label{label:q3}
        \end{figure}
    \end{parts}

\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:
        \begin{figure}[h]
            \includegraphics[scale=0.5]{test}
            \caption{Figure of Q.4}
            \label{label:q4}
        \end{figure}
    \end{parts}
\end{questions}
\end{document}

I am unable to upload the image test.jpg (of size 168x126) as well as the pdf I have created by running the above code. I am sorry for not able to upload the output I got.

0

1 Answer 1

10

The default maximum number of floats per page is three. In your case, you want the images to appear at precise locations, so don't use the floating environment figure; instead you can use minipages and \captionof from the capt-of or caption packages to get captions:

\documentclass[addpoints,11pt]{exam}
\usepackage[demo]{graphicx} %to display graphics!
\usepackage{afterpage}
\usepackage{caption}
\firstpagefootrule
\begin{document}
\begin{questions}
    \question[] True/False questions.
    \label{label:a}
        \begin{parts}
            \part[2] True or False.
            An image:

\begin{minipage}[t]{\linewidth}
                \centering
                \includegraphics[scale=0.5]{test}
                \captionof{figure}{Figure of Q.\ref{label:a}}
                \label{label:q1}
\end{minipage}
        \end{parts}


\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:

\begin{minipage}[t]{\linewidth}
                \centering
            \includegraphics[scale=0.5]{test}
            \captionof{figure}{Figure of Q.2}
            \label{label:q2}
        \end{minipage}
    \end{parts}

\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:

\begin{minipage}[t]{\linewidth}
                \centering
            \includegraphics[scale=0.5]{test}
            \captionof{figure}{Figure of Q.3}
            \label{label:q3}
        \end{minipage}
    \end{parts}

\question[] True/False questions.
    \begin{parts}
        \part[2] True or False.
        An image:

\begin{minipage}[t]{\linewidth}
                \centering
            \includegraphics[scale=0.5]{test}
            \captionof{figure}{Figure of Q.4}
            \label{label:q4}
        \end{minipage}
    \end{parts}
\end{questions}

\end{document}

enter image description here

The demo option for graphicx simply replaces actual figures with black rectangles; do not use that option in your actual document.

2
  • Thanks once again for another new testing command "demo" used in graphicx package. You know I was wondering why all black rectangles after running the modified code provided by you successfully. I even changed the picture to another and yet black rectangles. Later I put tikzpicture and show the figure, then I realize that it must be something to do with graphicx package and found the command. Thank you once again!
    – Khaaba
    Sep 13, 2012 at 13:40
  • @Khabba Sorry about that; when I use demo I usually place a little note warning about its usage and meaning, but I forgot it in my answer to your question; I'll add it right now. Sep 13, 2012 at 13:44

This site is temporarily in read-only mode and not accepting new answers.

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