0

I want to fix the spacing in the following and also wrap the texts around the long and short figure to the left. enter image description here

here is the MWE:

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=3.0cm]{geometry}
\usepackage[backend=biber, bibstyle=ieee, citestyle=numeric, sorting=none]{biblatex} % style=numeric
\AtEveryBibitem{
    \clearfield{urlyear}
    \clearfield{urlmonth}
}
\addbibresource{references.bib}
\usepackage{hyperref} % for hyperlinks, citations
\hypersetup{
    citecolor=green,
    colorlinks=True,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=blue,
    pdftitle={Thesis_organized},
    pdfpagemode=FullScreen,
    }
\urlstyle{same}
\usepackage{graphicx} %package to manage images
\graphicspath{{./Images/}} % 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[export, draft]{adjustbox}% for valign
\usepackage{enumerate}  
\usepackage{hyphenat}
\usepackage{MnSymbol}
\usepackage{siunitx} % for micro meter
\usepackage{amsmath} % for math fraction symbol
\usepackage{relsize} % for large summation
\usepackage[euler]{textgreek} % greek letters within text
\usepackage{bm} % bold math symbols
\usepackage{verbatim} % for commenting
\usepackage{lipsum} % for MWE
\usepackage{blindtext}
\usepackage{dirtytalk} % for quotes
\usepackage[
    textcolor=black,
    linecolor=red,
    bordercolor=red,
    % backgroundcolor=white,
        ]{todonotes}
\usepackage{tocloft} % to keep table on contents in a single page
% +---------------------------+
% |  for white space removal  |
% +---------------------------+
\usepackage{paracol}
% \usepackage{needspace} % to prevent wrapfigure going to the next page. 
\globalcounter*
\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}
% +------------------------+
% |   document starts      |
% +------------------------+
\begin{document}
% there are some other sections here... 

\section{Significance}
\input{Sections/03_Significance}
\label{sec:significance}
\addcontentsline{toc}{section}{References}
\printbibliography
% \bibliographystyle{ieee} %abbrv %apalike %ieeetr
% \bibliography{references}

% \addcontentsline{toc}{section}{Supplementary Information} 
% \section{Supplementary Information}
% \input{Sections/Supplementary_Information}

\end{document}
    \subsubsection{Ion image clustering and spectral classification}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut,
placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pel-
\savebox{\tempboxb}{\includegraphics[width=0.4\textwidth]{Images/meanionimageclusters.png}}% measure height
\savebox{\tempboxa}{\includegraphics[height=110mm, width=60mm]{Images/meanspecclusters.png}}%example-image-10x16}}% measure height
\setcolumnwidth{\dimexpr 0.64\textwidth-\columnsep}
\begin{paracol}{2}
\sloppy
\noindent \lipsum[2]
Nulla malesuada porttitor diam. Donec felis erat,
congue non, volutpat at, tincidunt tristique, libero. Vi-
vamus viverra fermentum felis. Donec nonummy pel-
lentesque 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
\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{average of ion image clusters}
            \label{mean ion}
        \end{subfigure}%\hfill
        % \hspace*{-2mm}
        \begin{subfigure}{\wd\tempboxa}
            \raisebox{0pt}[\ht\tempboxb]{\usebox\tempboxa}
           %\includegraphics[width=\linewidth]{figures/meanspecclusters.png}
            \subcaption{mean spectral distribution}
            \label{mean spec}
        \end{subfigure}
  \caption{The number of the clusters highlight tissue and spectral patterns.}\label{mean ion spec}
\end{figure}
\switchcolumn
\sloppy
\vspace*{-2.1cm}
\splitpar{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 
% Read more about the clustering method and sum of squared loadings (SSL) of PCA as a ranking metric in \hyperref[sec:SI]{supplementary informaiton} section.  
% \todo[color=yellow!]{fix spacing...}
}% write here for the next wrapped column.
\end{paracol}
\continuepar
7
  • You realize that \splitpar and \continuepar are custom macros. Aug 25, 2023 at 4:10
  • request to add the complete code staring with \begin{document} and finshing with \end{document}
    – js bibra
    Aug 25, 2023 at 4:12
  • you have tagged this wrapfigure but you are using figure which is always full width. Your code fragment is incomplete and can't be used to see the issue. Aug 25, 2023 at 8:06
  • @JohnKormylo I updated the MWE with relevant \usepackage info. Thanks.
    – banikr
    Aug 25, 2023 at 14:01
  • Thanks, but most of those packages are not relevant to the Minimal Working Example. Finding which packages are relevant and compatible is a part of the debugging process. Aug 25, 2023 at 14:34

1 Answer 1

1

The easy solution is to overlap the top of the figure with the taller image by using \smash. You need to leave a gap on the right side, which could be done with a minipage, but paracol with an empty column is easier w.r.t. \parindent and \strut. The key is where to place the \splitpar to match the height of the column to excess height of the taller image. (Knowing the height doesn't really help.)

\documentclass[a4paper,11pt]{article}
\usepackage[margin=3.0cm]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{paracol}
\usepackage{lipsum}

\globalcounter*

\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}
\lipsum[2]% normal width

\setcolumnwidth{\dimexpr \textwidth-60mm-\columnsep}% first width
\begin{paracol}{2}\sloppy
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut,
placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero,
nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pel-
Nulla malesuada porttitor diam. Donec felis erat,
congue non, volutpat at, tincidunt tristique, libero. Vi-
vamus viverra fermentum felis. Donec nonummy pel-
lentesque 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, \splitpar[\dimexpr 0.6\textwidth-60mm-\columnsep-2pt]%
{eleifend at, accumsan nec, suscipit
a, ipsum. Morbi blan-dit ligula feugiat magna. Nunc}
\end{paracol}

\setcolumnwidth{\dimexpr 0.6\textwidth-60mm-\columnsep-2pt}
\begin{paracol}{2}
\sloppy
\continuepar

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem
non justo. Nam lacus libero, \splitpar{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 parturient montes, nascetur ridiculus
mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus
luctus mauris.}
\switchcolumn
\begin{figure}[h]
  \captionsetup[subfigure]{justification=centering}
        \begin{subfigure}[b]{0.4\textwidth}
            \includegraphics[width=\linewidth]{example-image}%{Images/meanionimageclusters.png}
            \caption{average of ion image clusters}
            \label{mean ion}
        \end{subfigure}%\hfill
        \hfill
        \smash{\begin{subfigure}[b]{60mm}
            \includegraphics[height=110mm, width=60mm]{example-image}%{Images/meanspecclusters.png}}%example-image-10x16}}
            \subcaption{mean spectral distribution}
            \label{mean spec}
        \end{subfigure}}
  \caption{The number of the clusters highlight tissue and spectral patterns.}\label{mean ion spec}
\end{figure}
\end{paracol}
\continuepar
\end{document}
6
  • Thanks for the suggestion. But is it possible to do that with minipage? What I understand is minipage is probably easier to deal with than custom paracol package. See the updated MWE i added for generating the issue.
    – banikr
    Aug 25, 2023 at 14:03
  • The problem with minipage is that it sets \parindent=0pt. Also, it defaults to [c] which would require adding \strut at the beginning and end. \vbox would be better, but you would need to set \hsize to the desired width. BTW, I use "custom" to refer to anything not defined in a package (I wrote \splitpar). Aug 25, 2023 at 14:27
  • The suggestion you gave, it fills the top space of the figure but the wrapper part of the text to the left of short figure there are white spaces.
    – banikr
    Aug 25, 2023 at 14:40
  • Note that figure [h] adds an \intextsep gap above and below, If you don't leave enough room, there will be a discontinuity in the line spacing, so it is better to have too much space above and below than too little. Aug 25, 2023 at 15:05
  • I didn't understand, could you provide the suggestion again?
    – banikr
    Aug 25, 2023 at 21:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .