# Caption positioning with float package

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}


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. Jun 4, 2019 at 20:06
• Sometimes spaces are ignored. Usually this involves \par or \ignorespaces. Jun 4, 2019 at 22:45