Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
This answer may be useful for you (credits to @GonzaloMedina): tex.stackexchange.com/a/14826/5185 –  Nicolás Nov 29 '11 at 21:01
    
@Nicolás Could you give some more details how to adapt this to my example? –  student Dec 1 '11 at 13:53
    
That approach didn't work, so I tried another one that I'm going to write as an answer right now. –  Nicolás Dec 1 '11 at 19:07
add comment

2 Answers

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.

share|improve this answer
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 1 '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 Dec 1 '11 at 19:57
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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