TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem formatting my captions for figures/tables.

What should happen is the following: I need one line above the image and two lines above and below the caption. To make it look good, I have to adjust vertical spacing several times.

A problem now occurs depending on whether the caption is displayed in one or several lines. For single line captions I would need to adjust by the vspacing by {-0.8 \baselineskip}, in case of a multiline caption only by {-0.1 \baselineskip} for the line below the caption to have exactly the same space to the bottom of the text. I'm not so familiar with LaTeX or typesetting, so I don't understand why this happens at all. A solution would be to somehow figure out the number of lines in the caption, but I have no idea how to do this. I tried to "abuse" the lineno package for my needs, but without any success.

Has anyone an idea how to solve this or what causes the problem at all?

Below the code for my image insertion.

% example params: [0pt]{R}{.3}{afigurefile}{figure with long caption}{fig:afigure}
    \vskip -.8 \baselineskip
    \includegraphics[width=#3\textwidth, keepaspectratio]{#4}
    \vskip -1 \baselineskip
    \vskip -0.8 \baselineskip
    \vskip -.1 \baselineskip % for MULTI line captions
    % \vskip -.8 \baselineskip % for SINGLE line captions
share|improve this question
Hi Stefan, welcome! It is not customary to sign in the post here, I have removed that. Have a great stay! :) – zeroth Mar 6 '12 at 17:03
@zeroth: I will remember that. Thanks. – Stefan Mar 6 '12 at 21:28
up vote 7 down vote accepted

Unfortunately you didn't supply a minimal working example, so I don't know if you are using a class that uses the same caption code as article, however article uses:

  \sbox\@tempboxa{#1: #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1: #2\par
    \global \@minipagefalse

The #1: #2\par is the multi-line case, the \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% is the single line case, so you can redefine this command adding whatever spacing you need in each case.

share|improve this answer
Thanks, that gave me a great hint! I'm using KOMA-Script report-class and now found the \@@makecaption. It works essentially the same way (\ifdim-clause) and enables me to extend it with the necessary case-dependent line-drawing. – Stefan Mar 6 '12 at 21:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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