2

I would like to align the top of the text with a figure and add a caption with a label to it. But as soon as add

caption=test,figure

to the adjustbox the picture floats above the text.

How do I make this work?

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{ngerman}
\usepackage{chngcntr}

\usepackage{newunicodechar}

\usepackage{adjustbox}
\begin{document}
\begin{itemize}
\adjustbox{valign=t}{\begin{minipage}[t]{0.6\linewidth}
      \item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et     accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{minipage}}
\hfill
\adjustbox{valign=t, caption=test,figure}{\begin{minipage}[t]{0.3\linewidth}
    \includegraphics[width=\linewidth]{PICs/TestItemize.png}
\end{minipage}
}
\end{itemize}
\end{document}
simonides
  • 123
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. For example, I do not know where \picWidth comes from... – LaRiFaRi May 26 '15 at 14:18
  • I updated the code so it compiles, at least if a picture with the right name is present. My picture has a resolution of 1000x750 pixels. – simonides May 26 '15 at 14:25

2 Answers2

2

When you add figure to adjustbox options, you are declaring it as floating figure, then LaTeX places it as a floating object above text.

If you want an image with a caption can use \captionof command form caption package. A possible solution could look like:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{float}
\usepackage{ngerman}
\usepackage{chngcntr}
\usepackage{lipsum}
\usepackage{caption}
\usepackage{newunicodechar}

\usepackage{adjustbox}
\begin{document}

\lipsum[1]

\begin{itemize}
\item 
\adjustbox{valign=t}{\begin{minipage}[t]{0.6\linewidth}
      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et     accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{minipage}}
\hfill
\adjustbox{valign=t}{\begin{minipage}[t]{0.3\linewidth}
    \includegraphics[width=\linewidth]{example-image}
    \captionof{figure}{Figure}
\end{minipage}
}
\end{itemize}
\end{document}

enter image description here

Ignasi
  • 136,588
0

Maybe it is feasable for you to use a wrapfigure instead. Code taken from here:

% arara: pdflatex

\documentclass{article}
\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}
\begin{itemize}
  \item 
  \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
    \vspace{-2.4mm} % aliging to the bullet
    \begin{wrapfigure}[10]{r}{0.4\textwidth} % put the actual number of lines in the [...] part.
        \centering
        \vspace{-\baselineskip} % aligning to the top
        \includegraphics[width=0.3\textwidth, height=.225\textwidth]{PICs/TestItemize.png} % simulating the 1000x750
        \caption{test}
    \end{wrapfigure}
    \lipsum[1]
  }
  \item next item
\end{itemize}
\end{document}

enter image description here

LaRiFaRi
  • 43,807