0

I am using \setlength{\belowcaptionskip}{-10pt} from How can I reduce padding after figure? to reduce the spacing after my figures. And it is working fine.

But it is also affecting my new floats environments and reducing to almost 0 the spacing before the environment.

How can I fix my floats environments spacing before (keep their spacing) while keeping by figure environments reduced spacing after the figure? enter image description here

\documentclass[12pt]{memoir}
\usepackage{caption,newfloat}
\usepackage{graphicx}

\def\listofquadrosname{List of Frames}
\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},name=Frame,
within=chapter,listname=\listofquadrosname]{quadro}

\setlength{\belowcaptionskip}{-10pt}
\begin{document}
Before. Before. Before. Before. Before. Before. Before. Before. Before.

\begin{figure}[h]
    \includegraphics{latex.png}
    \caption{Opis}
\end{figure}

After. After. After. After. After. After. After. After. After. After.

Before. Before. Before. Before. Before. Before. Before. Before. Before.

\begin{quadro}[h]
\caption{Stuff.}
Contents.
\end{quadro}

After. After. After. After. After. After. After. After. After. After.
\end{document}
  • Use the caption package to control caption spacing above and below and instruct it that for quadros captions go above, thus inverse spacing. – daleif Jul 12 at 6:49
1

An easy way would be just to use the \vspace command e.g.

\documentclass[12pt]{memoir}
\usepackage{caption,newfloat}
\usepackage{graphicx}

\def\listofquadrosname{List of Frames}
\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},name=Frame,
within=chapter,listname=\listofquadrosname]{quadro}

\setlength{\belowcaptionskip}{-10pt}
\begin{document}
    Before. Before. Before. Before. Before. Before. Before. Before. Before.

    \begin{figure}[h]
        \includegraphics{example-image-a}
        \caption{Opis}
    \end{figure}

    After. After. After. After. After. After. After. After. After. After.

    Before. Before. Before. Before. Before. Before. Before. Before. Before.

    \vspace{5mm} % Increase the spacing before the enviroment
    \begin{quadro}[h]
        \caption{Stuff.}
        Contents.
    \end{quadro}

    After. After. After. After. After. After. After. After. After. After.
\end{document}
  • Sorry this is really bad advice. quadro is a float so may be moved to help with page breaking, but the vspace would stay in that place forcing a space between the two paragraphs in the main document flow. – David Carlisle Jul 12 at 6:48
0

After reading:

  1. How to disable paragraphs inside my environment with \let\par\relax?
  2. Please tutor the usage of patchcmd and xpatch

I managed to fix this by directly patching the figure environment, leaving all other environments intact:

\xpretocmd{\figure}{\setlength{\belowcaptionskip}{-10pt}}{}{}

Full example:

\documentclass[12pt]{memoir}
\usepackage{caption,newfloat}
\usepackage{graphicx}
\usepackage{xpatch}

\def\listofquadrosname{List of Frames}
\DeclareFloatingEnvironment[fileext=loq,placement={!hbtp},name=Frame,
within=chapter,listname=\listofquadrosname]{quadro}

\xpretocmd{\figure}{\setlength{\belowcaptionskip}{-10pt}}{}{}

\begin{document}
Before. Before. Before. Before. Before. Before. Before. Before. Before.

\begin{figure}[h]
    \includegraphics{latex.png}
    \caption{Opis}
\end{figure}

After. After. After. After. After. After. After. After. After. After.

Before. Before. Before. Before. Before. Before. Before. Before. Before.

\begin{quadro}[h]
\caption{Stuff.}
Contents.
\end{quadro}

After. After. After. After. After. After. After. After. After. After.
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.