6

I want to place a graphics to the right in a theorem environment containing a compactenum list. I tried to use parpic like this, but it doesn't work:

\documentclass{article}
\usepackage[pdftex]{graphicx}
\usepackage{picins}
\usepackage{enumerate}
\usepackage{paralist}
\usepackage{amsthm}
\theoremstyle{definition}%
\newtheorem{test}{test}

\begin{document}

\begin{test}
   \parpic[r]{\includegraphics[draft,width=6cm]{test.jpg}}
   Text, text, text,  text, text,  text, text,  text, text,  text, text,  text,
   text,  text, text,  text, text,  text, text,  text, text,
   \begin{compactenum}[a)]
      \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
      \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
   \end{compactenum}
\end{test}

\end{document}

The result looks like this:

result

Any idea how to fix this?

Edit:

I tried also Nicolás's solution below, however the image is not aligned at the top, this becomes clear if I add more text like this:

\documentclass[english]{article}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{amsthm}
\usepackage[demo]{graphicx}

\newtheorem{test}{test}
\begin{document}

 \noindent\parbox[b][][s]{\dimexpr\linewidth-5cm-5mm}{%
    \begin{test}
       Text, text, text,  text, text,  text, text,  text, text,  text, text,  text,
       text,  text, text,  text, text,  text, text,  text, text,
          \begin{itemize}
             \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
             \item  \blindtext

          \end{itemize}
    \end{test}
    } \hfill
    \includegraphics[draft,height=4cm, width=5cm]{imageName}

\end{document}

parbox

student
  • 29,003

2 Answers2

3

This solution is not as clean as I would have wanted, but it works anyway.

What you should do is:

  1. Enclose your theorem environment inside a parbox.
  2. Right after it you write:
    • hfill
    • Include the image with includegraphics:

So, the code you get is this:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{test}{Test theorem}

\begin{document}

    \noindent\parbox[b][][s]{\dimexpr\linewidth-5cm-5mm}{%
    \begin{test}
       Text, text, text,  text, text,  text, text,  text, text,  text, text,  text,
       text,  text, text,  text, text,  text, text,  text, text,
          \begin{itemize}
             \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
             \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
          \end{itemize}
    \end{test}
    } \hfill
    \includegraphics[height=4cm, width=5cm]{imageName}

\end{document}

I hope that it helps.

  • 2
    I guess it might be better to use a more image-oriented width for you \parbox. For example, \noindent\parbox[b][][s]{\dimexpr\linewidth-5cm} rather than \parbox[b][][s]{0.5\textwidth}, since the latter has no reference to the image width of 5cm. – Werner Dec 01 '11 at 19:50
  • @Werner: very good suggestion. I've just edited my answer to incorporate what you said, but I made the parbox 5mm narrower so that there is a small space between the text and the image. – Nicolás Ozimica Dec 01 '11 at 19:57
3

You can use two minipages with top alignment and \raisebox to place the image:

\documentclass[english]{article}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{amsthm}
\usepackage[demo]{graphicx}

\newtheorem{test}{test}

\begin{document}

 \noindent\begin{minipage}[t]{\dimexpr\linewidth-5cm-5mm}
\begin{test}
Text, text, text,  text, text,  text, text,  text, text,  text, text,  text,
text,  text, text,  text, text,  text, text,  text, text,
  \begin{itemize}
    \item  text,  text, text,  text, text,  text, text,  text, text, text,  text, text,  text, text,  text, text,  text, text
    \item  \blindtext
  \end{itemize}
\end{test}
\end{minipage}\hfill
\begin{minipage}[t]{5cm}
    \raisebox{-\height}{\includegraphics[draft,height=4cm, width=5cm]{imageName}}
\end{minipage}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128