5

Question: I wonder if it is possible to kindly tell LaTeX to put floats (automatically) either 1) some lines from the top of the page or 2) some lines from bottom of the page?

To clarify:

  • I know about the htbpH options of floats, none of them do what I'm asking for.
  • I still want the floats to float.
  • I don't have anything against if the floats appear in the middle of a paragraph, otherwise the H option would have been OK.
  • I am aware of this question, where it is asked where to put floats for a high typographic standard (but not how to do that in TeX).
  • I am somewhat aware of that TeX works very much with paragraphs, and that it might be a reason this is not possible. If so, that is an acceptable answer.

Background

In the nice typographical guide (in Swedish) "Sättningsregler" by W. N. Lansburgh (1961) it is suggested to place images like described above. Also, this is something one happens to find in older (pre TeX) books. Below, you find two example images I scanned from a book from 1904 where this placement is in action. (Hopefully with sufficiently low resolution, so that I do not violate some copyright law.)

Example images

Example page one Example page two

4
  • Yes, it's possible, but it requires very careful positioning. I'm not sure a figure in the middle of a paragraph (not at top or bottom of page) helps in readability, though.
    – egreg
    Oct 21, 2015 at 21:08
  • 1
    it's probably possible. perhaps but a bit risky as you would have very little information about what was "naturally" in the page at the point that you try to add the float, so you may find it has to go at the bottom anyway. But it wouldn't take too much code to make latex at least try to do this Oct 21, 2015 at 21:09
  • 1
    oh no!, @egreg and I posted comments in agreement, something must be wrong. Oct 21, 2015 at 21:10
  • @egreg I agree it might not be a good thing in the end. As far as I know, the typographical guide I mentioned in the post was very close connected with the typesetting of the journal Acta Mathematica at that time. I have not looked in the archives to see if they in Acta put images like described in this question, or not, though.
    – mickep
    Oct 22, 2015 at 5:47

1 Answer 1

6

So.. this just redefines b doing t as well would just be twice as much work (but too much for tonight:-) adding new "variant b" , say B while leaving the original b untouched would be possible but quite a bit more work as you'd need to find all the places where latex thinks it "knows" about the possible float areas and make it know about two more.

It basically lets the standard algorithm work, so leaving space for a float at the bottom of the page, then it vsplits the page arbitrarily 5 baselines up from the bottom, this may not actually split at that point, as it may be an equation or image or anything, but it will split somewhere and the figure is slotted in, note it uses half \textfloatsep above and below the figure (so the space adds up without having to make too many changes to latex, so you might want to increase that value....

enter image description here

three new "almost b" floats and one t

\documentclass[a4paper]{article}
\renewcommand\bottomfraction{.7}
\setcounter{bottomnumber}{1}% article default but don't change it:-)

\makeatletter
\def \@cflb {%
    \let\@elt\@comflelt
    \setbox\@tempboxa \vbox{}%
    \@botlist
    \setbox\@outputbox \vbox{%
%start of change
\setbox\tw@\vsplit\@outputbox to\dimexpr\ht\@outputbox-5\normalbaselineskip\relax
\unvbox\tw@
\vskip .5\textfloatsep
\unvbox\@tempboxa
\vskip -\floatsep
\vskip .5\textfloatsep
\unvbox\@outputbox
%end of change
                             }%
    \let\@elt\relax
    \xdef\@freelist{\@freelist\@botlist}%
    \global \let \@botlist\@empty
}
\makeatother



\errorcontextlines1000
\def\a{One \refstepcounter{enumi}\theenumi\ two \Roman{enumi}, three four chicken dug dog elephant penguin,\ifnum\value{enumi}<27\ \alph{enumi}\fi. }
\def\b{\a\a\a\a\begin{equation}\theenumi+1=\refstepcounter{enumi}\theenumi\end{equation}\a\a\a\ifodd\value{enumi}\a\a\fi\par}
\def\c{\a\a\b\a\a\b\b\a}
\newcommand\f[2][b]{\begin{figure}[#1]\centering\rule{5cm}{\ifodd\value{figure} 3cm\else6cm\fi}\caption{#2}\end{figure}}
\begin{document}

\a
\f[b]{zz}
\c
\c

\f{qq}
\a
\f{jj}
\f[tp]{ttt}
\b

\c\c
\end{document}
3
  • Wow, thank you very much! This is indeed a proof of concept. Is it OK if I ask for the way of introducing a B float placement option instead of changing the b one (that could be good to have intact), or is it better if I ask that as a new question?
    – mickep
    Oct 22, 2015 at 5:44
  • @mickep I may look later but you have to search for every place that latex checks each float area in sequence and add in the new area at the right point in the sequence so it will be a lot more changes, and to be honest it may not be worth it, if you allow both b and B floats you need to worry about the order you put them on the page and if you end up needing to split up \@botlist into two it would be a lot more changes, but I haven't looked at code yet, perhaps there is a way without so many. It would certainly be a lot more code than this though:-) Oct 22, 2015 at 6:52
  • I will accept this answer, since I feel it answers my original question very well. I might come back and ask about technicalities. In fact, I think a package that would implement the B and a T placement options would be very nice, but 1) I'm not able to write it and 2) maybe I'm the only one being interested in it. Again, thanks for your excellent answer!
    – mickep
    Oct 22, 2015 at 9:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .