Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the following example, the columns on page 1 and 3 "sit" perfectly on the frame, while on page 2 (with the large float) the columns end a bit above the frame. Does anyone have an idea what I could do to get around the problem? (If a perfect solution is not possible, then a difference of 1-2pt would be acceptable).

Using a \parskip with stretchable part helps naturally but is not what I'm looking for. Setting \dbltextfloatsep to a specific value helps, too (in this case to 24.8pt), but it's dependent on the size of the figure and it is tiresome to find the "correct" value.

\documentclass[a4paper,twocolumn]{book}
\usepackage{lipsum}
\usepackage[showframe,
           textheight=\dimexpr\topskip+45\baselineskip\relax]{geometry}
%\parskip=0pt plus 1pt
\parskip=0pt 

%\dbltextfloatsep=24.8pt

\begin{document}
\begin{figure*}
\rule{\textwidth}{5cm}
\caption{blub}
\end{figure*}

\lipsum \lipsum
\end{document}
share|improve this question
    
i think this might be a suitable question to report to latex bugs; i didn't see any related questions with a quick look. a possible automatic approach might be to calculate the difference between the page height and the figure height, subtract \dbltextfloatsep, subtract \topskip and however many normal baselines will fit, and add the residue to \dbltextfloatsep (which appears to be what you've done for this one case). but it's not clear to me where one would add it to make it automatic. –  barbara beeton Oct 16 '12 at 15:08
3  
It seems to me that if \dbltextfloatsep had enough stretch eg \dbltextfloatsep=20.0pt plus 1\baselineskip minus 4.0pt then it ought to pad things out so the descenders on the bottom row overhang the column, but it doesn't even though each column box ends with a -ve vskip to compensate for the descenders. Staring at latex.ltx.... –  David Carlisle Oct 16 '12 at 16:15
1  
@David: Sorry I should have written that amongst other I also tried with (very) stretchable \dbltextfloatsep. But actually I don't see how it could do the "right" thing: The output routine has to put the float at the top (and insert \dbltextfloatsep) and then give back the smaller page rest to the normal page builder to fill it with text and so this rest must have the correct size. I think I must rephrase the question: How can I make sure that the figure has a total height which is a multiple of \baselineskip? –  Ulrike Fischer Oct 17 '12 at 7:54
    
I think it is supposed to work, but the output routine is leaving a box boxed rather than unboxed and not allowing any stretch but I have little tex time this week. The modified question is easier as you can box the contents and measure and (especially if you make floatsep and textfloatsep the same or at least the same modulo baselineskip) it is easy to ensure the box you put into the float, + floatsep is a multiple of baselineskip –  David Carlisle Oct 17 '12 at 8:25

1 Answer 1

up vote 11 down vote accepted

As David Carlisle explains in his comment, the \dbltextfloatsep glue is emitted in a place where it can't stretch or shrink.

I've got the correct height by loading the figure, typesetting it for getting its height and inserting a skip for compensating the difference to a whole number of lines.

\documentclass[a4paper,twocolumn,draft]{book}
\usepackage{lipsum}
\usepackage[showframe,lines=46]{geometry}
\usepackage{environ}
\makeatletter
\NewEnviron{Figure}{%
  \setbox0=\vbox{\hsize=\textwidth
    \def\refstepcounter##1{}\def\label##1{}
    \def\@captype{figure}
    \BODY
  }
  \dimen0=\dimexpr\ht0+\dbltextfloatsep\relax
  \count255=\dimen0
  \divide\count255\baselineskip
  \dimen0=\dimexpr\numexpr(1+\count255)\baselineskip-\dbltextfloatsep-\ht0\relax
  \begin{figure*}
  \BODY
  \vskip\dimen0
  \end{figure*}
}

\parskip=0pt 
%\dbltextfloatsep=20pt % set at pleasure


\begin{document}

\lipsum[1-5]

\begin{Figure}
\centering
\rule{\textwidth}{5cm}

\caption{blub}
\end{Figure}

\lipsum[6-7]\lipsum\lipsum
\end{document}
share|improve this answer
2  
Perfect. I added an optional argument (\NewEnviron{Figure}[1][tbp]) to grab the optional of figure*, and then it worked like a charm in my real world example. Thank you. –  Ulrike Fischer Oct 17 '12 at 17:41
2  
@UlrikeFischer I can think of extreme cases in which this can fail (for instance, a change in the figure number to a two digit one that can trigger different typesetting of the caption), so some improvements might be needed. This seems to me a LaTeX bug that should be reported. For now, waiting for Frank, I'm honored to have the first answer you've accepted. –  egreg Oct 17 '12 at 18:08

Your Answer

 
discard

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.