1

I'm using the float package and I defined a new float environment. I noticed that when there's a figure inside float with width=\textwidth the space between the figure and the caption is doubled. However, when it's something like width=0.9\textwidth or other number, the space is the standard for a float environment.

I simply use \vspace{-\abovecaptionskip} when the figure has the width of the text, but I don't know why this happens and if there is some explanation.

\documentclass[draft]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx}

\usepackage{float}
\newfloat{scheme}{htbp}{schemes}

\begin{document}

    \begin{scheme}[h]
        \centering
        \includegraphics[width=\textwidth]{}
        \caption{Lorem ipsum}
    \end{scheme}

\end{document}
1

Missing % after \includegraphics[width=\textwidth]{}; this creates a space which starts a new line:

\documentclass[draft]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}

\usepackage[demo]{graphicx}

\usepackage{float}
\newfloat{scheme}{htbp}{schemes}

\begin{document}

    \begin{scheme}[h]
        \centering
        \includegraphics[width=\textwidth]{}%
        \caption{Lorem ipsum}
    \end{scheme}

        \begin{scheme}[h]
            \centering
            \includegraphics[width=.9\textwidth]{}%
            \caption{Lorem ipsum}
        \end{scheme}

\end{document}
  • I see, but it is strange that this space won't appear in a float like figure neither when the width is different from \textwidth. – Daniel Álvarez Jun 4 at 20:06
  • Sometimes spaces are ignored. Usually this involves \par or \ignorespaces. – John Kormylo Jun 4 at 22:45

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.