我想将文本顶部与图形对齐,并添加带有标签的标题。但一旦添加
caption=test,figure
到调整框,图片浮动在文本上方。
我该如何让它工作?
\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}
答案1
当您添加figure
到adjustbox
选项时,您将其声明为floating
图形,然后LaTeX
将其作为文本上方的浮动对象放置。
caption
如果您想要一个可以使用\captionof
命令形式包的图像caption
。一个可能的解决方案可能是这样的:
\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}
答案2
也许你可以改用wrapfigure
。代码取自这里:
% 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}