如何用子图填充包装图中的空白

如何用子图填充包装图中的空白

我有以下页面,我想用段落填充空白处(红色图画)。 在此处输入图片描述

已经有帖子和解决方案这里:这非常麻烦,我可能必须更改所有小节的所有段落长度,正如其中一条评论所提到的那样。有没有更简单的方法来实现我的需求?

我将尝试发布我的 MWE:

        \usepackage{graphicx} %package to manage images
        \graphicspath{ {./figures/} } % folder where the images or figures are
        \usepackage{subcaption}
        \usepackage[labelfont=bf]{caption} % make Figure 1 bold
        \usepackage{wrapfig} % for wrapping a figure with words
        \usepackage{lipsum}
        \begin{document}
        ....
        \subsubsection{demo subsection}
        \lipsum[1]
        \begin{wrapfigure}{h}{0.8\textwidth}
            \begin{minipage}{\linewidth}
                \centering\captionsetup[subfigure]{justification=centering}
                \begin{subfigure}{0.45\textwidth}
                    \includegraphics[width=\linewidth]{figures/universe.jpg}
                    \subcaption{}
                    \label{fig:5a}\par\vfill
                \end{subfigure}
                \begin{subfigure}{0.45\textwidth}
                    \includegraphics[width=\linewidth]{figures/meanspecclusters.png}
                    \subcaption{}
                    \label{fig:5b}
                \end{subfigure}
            \end{minipage}
        \caption{Figure}\label{fig:5}
        \end{wrapfigure}
        \lipsum[2]
        ....
        \end{document}

答案1

理论上,你可以用两个连续的 wrapfigure 来实现这一点,但你仍然需要在两个 wrapfigure 之间手动分段。如果你要手动分段,你不妨使用 paracol(更可靠)。

基本思想是留下一个空白空间,以便可以将较大的图像重叠到其中。

\documentclass{article}
\usepackage{graphicx} %package to manage images
%\graphicspath{ {./figures/} } % folder where the images or figures are
\usepackage{subcaption}
\usepackage[labelfont=bf]{caption} % make Figure 1 bold
\usepackage{paracol}
\globalcounter*
\usepackage{lipsum}

\newsavebox{\tempboxa}
\newsavebox{\tempboxb}

\newsavebox{\textbox}
\newcommand{\splitpar}[2][\textwidth]{% #1 = width of column (optional), #2 = rest of paragraph after split
  \unskip\strut{\parfillskip=0pt\parskip=0pt\par}%
  \global\setbox\textbox=\vbox{\hsize=#1\relax\noindent\strut #2\strut}}
\newcommand{\continuepar}{\unvbox\textbox}

\begin{document}
        \subsubsection{demo subsection}
        \lipsum[1]
        \savebox{\tempboxa}{\includegraphics[width=0.36\textwidth]{example-image-10x16}}% measure height
        \savebox{\tempboxb}{\includegraphics[width=0.36\textwidth]{example-image}}% measure height
        \setcolumnwidth{\dimexpr 0.64\textwidth-\columnsep}
        \begin{paracol}{2}
        \sloppy
Nam dui ligula, fringilla a, euismod sodales,
sollicitudin vel, wisi. Morbi auctor lorem non
justo. Nam lacus libero, pretium at, lobortis
vitae, ultricies et, tellus. Donec aliquet, tortor
sed accumsan bibendum, erat ligula aliquet
magna, vitae ornare odio metus a mi. Morbi
ac orci et nisl hendrerit mollis. Suspendisse ut
massa. Cras nec ante. Pellentesque a nulla. Cum
sociis natoque penatibus et magnis dis parturi ent
\splitpar[\dimexpr 0.28\textwidth-2\columnsep]{%
montes, nascetur ridiculus mus. Aliquam
tincidunt urna. Nulla ullamcorper vestibulum
turpis. Pellentesque cursus luctus mauris.}
        \switchcolumn
        \rule{0pt}{\dimexpr \ht\tempboxa-\ht\tempboxb}% empty space
        %\hrule% show bottom of empty space
        \end{paracol}
        \setcolumnwidth{\dimexpr 0.28\textwidth-2\columnsep}
        \begin{paracol}{2}
        \continuepar
        \switchcolumn
        \begin{figure}[h]
          \captionsetup[subfigure]{justification=centering}
                \begin{subfigure}{\wd\tempboxb}
                    \usebox\tempboxb
                    \caption{}
                    \label{fig:5a}
                \end{subfigure}\hfill
                \begin{subfigure}{\wd\tempboxa}
                    \raisebox{0pt}[\ht\tempboxb]{\usebox\tempboxa}
                    \subcaption{}
                    \label{fig:5b}
                \end{subfigure}
          \caption{Figure}\label{fig:5}
        \end{figure}
        \switchcolumn
        \sloppy
Nulla malesuada
porttitor diam. Donec
felis erat, congue
\splitpar{non, volutpat at,
tincidunt tristique,
libero. Vivamus
viverra fermentum
felis. Donec
nonummy pellentesque
ante. Phasellus
adipiscing semper
elit. Proin fermentum
massa ac
quam. Sed diam
turpis, molestie vitae,
placerat a, molestie
nec, leo. Maecenas
lacinia. Nam
ipsum ligula, eleifend
at, accumsan
nec, suscipit a, ipsum.
Morbi blandit
ligula feugiat magna.
Nunc eleifend
consequat lorem.
Sed lacinia
nulla vitae enim.
Pellentesque tincidunt
purus vel magna.
Integer non
enim. Praesent euismod
nunc eu purus.
Donec bibendum
quam in tellus.
Nullam cursus pulvinar
lectus. Donec
et mi. Nam
vulputate metus eu
enim. Vestibulum
pellentesque felis eu
massa.}
        \end{paracol}
        \continuepar
\end{document}

相关内容