4

I am getting this ugly gap between subfigures and the top margin. I'm really puzzled because when it's only one figure it's nicely aligned. How can I align my subfigures to the top margin?

I'm using koma-script book, but the problem persists when I change to book.

\documentclass[11pt,english,british]{scrbook}

\usepackage{mathptmx}
\usepackage[showframe, paperwidth=17cm,paperheight=23cm]{geometry}
\usepackage[draft]{graphicx}
\usepackage{subfig}
\usepackage{lipsum}

\geometry{verbose,tmargin=2.2cm,bmargin=2.5cm,lmargin=2.1cm,rmargin=1.3cm,footskip=1cm}

\begin{document}

\lipsum

\begin{figure}
\centering{}\rule{0.5\textwidth}{0.5\textwidth}%
\caption{Single figure nicely aligned}%
\end{figure}

\lipsum[5]

\begin{figure}
\centering%
\subfloat[First subfigure]{\rule{0.49\textwidth}{5cm}}%
\hfill%
\subfloat[Second subfigure]{\rule{0.49\textwidth}{5cm}}%
\caption{Group of figures with ugly gap on top}%
\end{figure}

\end{document}

enter image description here

6

It's done on purpose by subfig, which uses a couple of parameters for adding vertical space between rows of subfloats.

Use \captionsetup{farskip=0pt} where you want the space to disappear. Note that I have reduced the code to a MWE, add back the packages and settings you need.

\documentclass[11pt]{scrbook}

\usepackage[pass,showframe]{geometry}
\usepackage{subfig}
\usepackage{lipsum}

\begin{document}

\lipsum

\begin{figure}[htp]
\centering{}\rule{0.5\textwidth}{0.5\textwidth}%
\caption{Single figure nicely aligned}%
\end{figure}

\lipsum[5]

\begin{figure}[tp]
\captionsetup{farskip=0pt}% <--- no gap at the top
\centering
\subfloat[First subfigure]{\rule{.49\textwidth}{5cm}}%
\hfill
\subfloat[Second subfigure]{\rule{.49\textwidth}{5cm}}%

\caption{Group of figures with ugly gap on top}
\end{figure}

\lipsum

\end{document}

enter image description here

| improve this answer | |

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.