1

Sometimes, there is need to adjust the spacing between the caption and the figure in figwindow environment by picinpar package in LaTeX. So, how to complete this action?

For example:

\documentclass{article}
\usepackage{picinpar,graphicx}
\begin{document}
\begin{figwindow}[3,r,{\includegraphics[width=0.4\textwidth]{example-image-a}},{hello}\label{fig:title}]
    The figure environment takes care of the numbering and positioning of the image within the document. In order to include a figure, you must use the includegraphics command. It takes the image width as an option in brackets and the path to your image file. As you can see, I put linewidth into the brackets, which means the picture will be scaled to fit the width of the document. As a result smaller pictures are upscaled and larger pictures downscaled respectively. As I mentioned before the brackets contain the path to the image. In this case the image is stored in the same directory as my .tex file, so I simply put boat.jpg here to include it. For large documents, you probably want to store image files in a different folder, say we created a folder images, then we would simply write images/boat.jpg into the braces. In the next command we set a caption, which is the text shown below the image and a label which is invisible, but useful if we want to refer to our figure in our document. You can use the ef command to refer to the figure (marked by label) in your text and it will then be replaced by the correct number. LaTeX is smart enough to retrieve the correct numbers for all your images automatically. Note that you will need to include the graphicx package in order to use this code.
\end{figwindow}
\end{document}

This will produce: the figure

When change \begin{figwindow}[3,r,{\includegraphics[width=0.4\textwidth]{example-image-a}},{hello}\label{fig:title}] to \begin{figwindow}[3,r,{\includegraphics[width=0.4\textwidth]{example-image-a}},{\vspace{1cm}hello}\label{fig:title}], the output is the same.

Thanks.

Ingmar
  • 6,690
  • 5
  • 26
  • 47
Y. zeng
  • 1,885
  • If you replace \vspace{1cm} by, say, \vphantom{\begin{tabular}[t]{c} \vspace{1cm} \end{tabular}} you will create additional space. –  Apr 09 '23 at 02:07
  • @Displayname Thanks. But this way adjust the spacing between the caption and the text not the figure and the caption. – Y. zeng Apr 09 '23 at 04:22
  • In that case, use \begin{tabular}[b]{c} .... (Needless to say that this is not a proper solution but at best a workaround.) –  Apr 09 '23 at 04:25
  • @Displayname Is there a way to adjust the spacing between the figure and the caption? – Y. zeng Apr 09 '23 at 04:28
  • As I said: \begin{figwindow}[3,r,{\includegraphics[width=0.4\textwidth]{example-image-a}},{% \vphantom{\begin{tabular}[b]{c} \vspace{1cm} \end{tabular}}% hello}\label{fig:title}]. This is a way but not very clean nor illuminating. –  Apr 09 '23 at 04:30
  • @Displayname I tested it. But what has been adjusted is the spacing between the caption and the text below the caption, not the spacing between the figure and the caption. – Y. zeng Apr 09 '23 at 04:32
  • Interesting. Either I do not understand what you are saying or our Latex installations give different results. Sorry that I cannot help... –  Apr 09 '23 at 04:35
  • @Displayname Thank you very much. This way can work: \begin{figwindow}[3,r,{\vphantom{\begin{tabular}[t]{c} \vspace{1cm} \end{tabular}}\includegraphics[width=0.4\textwidth]{example-image-a}},{hello}\label{fig:title}]. However, only \vspace{acm} works if a is bigger than 0. If it is a negative number, it wouldn't work. – Y. zeng Apr 09 '23 at 04:37

1 Answers1

1

The MWE show how to add some vertical space before and/or after the caption:

enter image description here

\documentclass{article}
\usepackage{picinpar,graphicx,lipsum}
\begin{document}
\begin{figwindow}[4,r,{%
\includegraphics[width=0.4\textwidth]{example-image-a}
\vspace{2cm}},  % <=== space before the caption 
{hello everybody}\label{fig:title}%
\par\vspace{2cm}] % <=== space after the caption 
\lipsum[1-3]
\end{figwindow}
\end{document}
Fran
  • 80,769
  • Thanks. When you change the number of the first \vspace{2cm}, you will that figure is moved a little vertically. Why? For example, if you change \vspace{2cm} to \vspace{1cm}, the figure will be moved down a little. – Y. zeng Apr 09 '23 at 08:57
  • I guess that is because 1cm or 2cm ad an imperfect number of lines of text and latex must add different glues in each case to round to height that is an integer number of lines. Try with \vspace{x\baselineskip} and whatever the value of "x" (1,2,3...) the image will no move. – Fran Apr 09 '23 at 09:19
  • You will see this also if you change only the height of the image some mm, e.g., in my MWE adding height=1cm ther are some space above but increasing this height up to 1.3cm the space above (and below) is reduced, whereas pincipar window do not change. If you increase the height to 1.33cm, shrink the spaces is not enough, therefore the window take one more line of text, and the spaces above and below must stretch again to fill all the available space. – Fran Apr 09 '23 at 10:19
  • Yes. That is the reason. Thanks. – Y. zeng Apr 09 '23 at 10:49