How can I put a graph next to the question?

Added by Paco Riviere about 4 years ago

How can I put a graph next to the question. It would allow me to save half the pages as I have space next to it. I have tried several options and it always comes out below. I mean something like this: https://sharelatex-wiki-cdn-671420.c.cdn77.org/learn-scripts/images/7/7b/InsertingImagesEx10.png


Replies (7)

RE: How can I put a graph next to the question? - Added by Paco Riviere about 4 years ago

I imagine it should be something like this:

\begin{wrapfigure}{r}{0.5\textwidth}
\begin{center}
\includegraphics[width=0.48\textwidth]{birds}
\end{center}
\caption{Birds}
\end{wrapfigure}

Taken from: https://www.overleaf.com/learn/latex/wrapping_text_around_figures

Tried this way, on a working project:

\element{6.2.1 Central electrica}{
\begin{question}{c.hidro-wrapped}
\begin{wrapfigure}{r}{32mm}
\vspace{-2\baselineskip}
\begin{center}
\includegraphics[width=30mm]{./Figures/chidroe.png}
\end{center}
\end{wrapfigure}
La figura mostra
\begin{choices}
\correctchoice{una central hidroelèctrica}
\wrongchoice{una central tèrmica}
\wrongchoice{una central nuclear}
\wrongchoice{una central geotèrmica}
\end{question}
\vspace{5\baselineskip}}

And got this message:

[1 <./Figures/partscnuclear.jpg>] [2]
! LaTeX Error: Environment wrapfigure undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.

Any light would be very welcomed

RE: How can I put a graph next to the question? - Added by Paco Riviere about 4 years ago

I forgot the line:

\end{choices}

Anyway, I get the same result after adding the missing line:

[@1 <./Figures/partscnuclear.jpg>] [2]
! LaTeX Error: Environment wrapfigure undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.932 }

! LaTeX Error: \begin{minipage} on input line 932 ended by \end{wrapfigure}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

@

RE: How can I put a graph next to the question? - Added by Paco Riviere about 4 years ago

Got it!

Need the package:

\usepackage{wrapfig}

!!

RE: How can I put a graph next to the question? - Added by Paco Riviere about 4 years ago

Unfortunately, next question writes down over this picture. Pic enclosed

Any idea?

Btw. Neither know why question text starts on next line. Compre with next question.

RE: How can I put a graph next to the question? - Added by Alexis Bienvenüe about 4 years ago

Try enclosing the choices and the figure into two parbox'es.

\begin{question}{test}
  \parbox[c]{.46\linewidth}{
     Question
     \begin{choices}
       ...
     \end{choices}
  }
  \parbox[c]{.46\linewidth}{
    ...figure...
  }
\end{question}

RE: How can I put a graph next to the question? - Added by Agustin Martin about 3 years ago

Hi,

I use graphics in questions on a regular basis, mixing questions, choices and figure inside minipages in different ways. For my convenience I wrote a small AMC file showing some of the different combinations I used, some look better and some look worse, but I found useful to keep it available. For questions of this kind you will need some fine tuning, but when done, result looks good. I use the keys=line option to avoid displayed keys mess with question layout in catalog mode, so I get a view closer to that for students.

I am attaching a groups.tex file with these questions and resulting DOC-catalog.pdf. Hope it is useful.

groups.tex (9.2 kB)

DOC-catalog.pdf (68.1 kB)

(1-7/7)