1

I have a problem with the package "exam". I want to put in the orizontal direction 4 images. And move every circle close to the middle of every image. I have post the picture. Thank you very much.

\begin{oneparcheckboxes}
 \begin{figure}[!h]
  \centering
  \captionsetup{font={small,it}, labelfont=bf}
  %\subfloat[][\emph{}] % didascalia sottofigura
  {\choice \includegraphics[width=0.2\textwidth]{grafico_9.pdf}} \quad
  \captionsetup{font={small,it}, labelfont=bf}
  %\subfloat[][\emph{}] % didascalia sottofigura
  {\choice\includegraphics[width=.2\textwidth]{grafico_9.pdf}} \quad
 % \subfloat[][\emph{}] % didascalia sottofigura
  {\choice\includegraphics[width=.2\textwidth]{grafico_9.pdf}} \quad
  % \subfloat[][\emph{}] % didascalia sottofigura
  {\choice\includegraphics[width=.2\textwidth]{grafico_9.pdf}} \\
  \end{figure}
 \end{oneparcheckboxes}

enter image description here

4
  • 2
    Could you please make your example a complete document, so we can compile it directly? You are likely to get more help here if you do.
    – Thruston
    Jan 3, 2016 at 23:06
  • 1
    Why do you have a figure environment nested inside the oneparcheckboxes environment?
    – Thruston
    Jan 3, 2016 at 23:06
  • 1
    See here: tex.stackexchange.com/questions/7219/…
    – Thruston
    Jan 3, 2016 at 23:25
  • 1
    This is not a problem with the exam class. It's a general problem of how to vertically centre a graphic. Basically get rid of the figure stuff and use \choice $\vcenter{\hbox{\includegraphics[width=0.2\textwidth]{grafico_9.pdf}}}$ for each item
    – Thruston
    Jan 3, 2016 at 23:27

1 Answer 1

2

You want something more like this:

\documentclass{exam}
\usepackage{graphicx}
\begin{document}
\begin{oneparcheckboxes}
\choice $\vcenter{\hbox{\includegraphics[width=0.15\textwidth]{yourgraphicfile}}}$
\quad
\choice $\vcenter{\hbox{\includegraphics[width=0.15\textwidth]{yourgraphicfile}}}$
\quad
\choice $\vcenter{\hbox{\includegraphics[width=0.15\textwidth]{yourgraphicfile}}}$
\quad
\choice $\vcenter{\hbox{\includegraphics[width=0.15\textwidth]{yourgraphicfile}}}$
\end{oneparcheckboxes}
\end{document}

If you are doing this a lot, then you could hide the details by defining a new command:

\documentclass{exam}
\usepackage{graphicx}
\newcommand{\vpic}[1]{$\vcenter{\hbox{\includegraphics[width=0.15\textwidth]{#1}}}$}
\begin{document}
\begin{oneparcheckboxes}
    \choice \vpic{yourgraphicfile} \quad
    \choice \vpic{yourgraphicfile} \quad
    \choice \vpic{yourgraphicfile} \quad
    \choice \vpic{yourgraphicfile}
\end{oneparcheckboxes}
\end{document}
5
  • yes! it's perfect! it works very wel! :) thanks a lot!
    – ryuk
    Jan 3, 2016 at 23:42
  • 2
    Also \raisebox{-.5\height}{\includegraphics[...]{...}}; the difference is negligible. Or \begin{tabular}{@{}c@{}}\includegraphics[...]{...}\end{tabular}.
    – egreg
    Jan 3, 2016 at 23:45
  • 1
    @egreg sì certo, and several other options that are discussed in the question I linked.
    – Thruston
    Jan 3, 2016 at 23:48
  • 1
    It has always surprised me that there is no [vcenter] option for the \includegraphics command.
    – Thruston
    Jan 3, 2016 at 23:53
  • 1
    @Thruston There is valign=m if you load adjustbox with the export option
    – egreg
    Jan 4, 2016 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.