How can I put a graph next to the question?

Added by Paco Riviere 12 months 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 (6)

RE: How can I put a graph next to the question? - Added by Paco Riviere 12 months 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 12 months 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 12 months ago

Got it!

Need the package:

\usepackage{wrapfig}

!!

RE: How can I put a graph next to the question? - Added by Paco Riviere 12 months 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 12 months 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}

(1-6/6)