如何使用 wrapfig 代码垂直提升图像?

如何使用 wrapfig 代码垂直提升图像?
\documentclass[a4paper, 12pt]{article}
%Paragraph jumps and indentation
\setlength{\parindent}{1.27cm}
%Border
\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}



\vfill
\noindent
\begin{minipage}{0.5\linewidth}
$r$ = 3 cm\\
$h$ = 15 cm\\
$l$ (not used) = 17 cm\\
$V$ (listed on packaging) = 125 ml\\
\end{minipage}
\begin{minipage}{0.4\linewidth}
    \includegraphics[width=\linewidth]{ice cream oreo.png}
        \caption{Figure 1: Dimensions of Igloo Cookies \& Cream cone ice cream}
\end{minipage}\hfil
\end{document}

我的代码显示错误:标题超出浮动范围

答案1

请尝试以下操作:

\documentclass[a4paper, 12pt]{article}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{1.27cm}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{siunitx}

\begin{document}
\noindent
\begin{minipage}{0.5\linewidth}
    \begin{align*}
                              r & = \qty{3}{\centi\metre}\\
                              h & = \qty{15}{\centi\metre}\\
            l \text{(not used)} & = \qty{17}{\centi\metre}\\
V \text{(listed on packaging)}  & = \qty{125}{\milli\litre}
    \end{align*}
\end{minipage}%
    \hfill%
\begin{minipage}{0.4\linewidth}
    \includegraphics[width=\linewidth]{example-image-duck}  %{ice cream oreo.png}
    \captionof{figure}{Dimensions of Igloo Cookies \& Cream cone ice cream}
\end{minipage}
\end{document}

在此处输入图片描述

附录 或者使用adjustbox包:

\documentclass[a4paper, 12pt]{article}
\usepackage[margin=1in]{geometry}
\setlength{\parindent}{1.27cm}
\usepackage[export]{adjustbox}% it load graphicx package too
\usepackage[skip=1ex, font=small,labelfont=bf]{caption}
\usepackage{amsmath}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}
\lipsum[11]

\begin{center}
\begin{minipage}[t]{0.7\linewidth}
    \begin{align*}
                               r & = \qty{3}{\centi\metre}\\
                               h & = \qty{15}{\centi\metre}\\
            l \text{ (not used)} & = \qty{17}{\centi\metre}\\
V \text{ (listed on packaging)}  & = \qty{125}{\milli\litre}
    \end{align*}
\end{minipage}%
\begin{minipage}[t]{0.3\linewidth}
    \includegraphics[width=\linewidth,valign=t]{example-image-duck}  %{ice cream oreo.png}
    \captionof{figure}{Dimensions of Igloo Cookies \& Cream cone ice cream}
\end{minipage}
\end{center}
\lipsum[12]
\end{document}

在此处输入图片描述

答案2

这说明了如何使用 paracol 来实现所需的结果。

\documentclass[a4paper, 12pt]{article}
%Paragraph jumps and indentation
\setlength{\parindent}{1.27cm}
%Border
\usepackage[left=1in, right=1in, top=1in, bottom=1in, showframe]{geometry}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{paracol}

\begin{document}

\setcolumnwidth{0.5\linewidth}
\begin{paracol}{2}
\null\vfil\noindent% center text vertically
$r$ = 3 cm\\
$h$ = 15 cm\\
$l$ (not used) = 17 cm\\
$V$ (listed on packaging) = 125 ml\\
\switchcolumn
\begin{figure}[h]
    \includegraphics[width=\linewidth]{example-image}
    \caption{Dimensions of Igloo Cookies \& Cream cone ice cream}
\end{figure}
\end{paracol}
\hrule% show bottom of area used

\end{document}

相关内容