6

If a figure will fit on the bottom of the page, it will also fit at the top of the page and will wind up there (barring certain circumstances). The best I have come up with is to set topnumber to 0 (default).

Is there a better way to achieve this?

\documentclass{article}
\usepackage{lipsum}
\usepackage{everypage,afterpage}

\setcounter{topnumber}{0}
\setcounter{bottomnumber}{2}
\renewcommand{\bottomfraction}{.7}

\begin{document}
\lipsum[1-2]
%\lipsum[3-4]% for top of next page

\AddThispageHook{\stepcounter{topnumber}}
\afterpage{\addtocounter{topnumber}{-1}}
\begin{figure}[tb]
\rule{\textwidth}{.2\textheight}
\caption{test}
\end{figure}

\lipsum[5-12]

\end{document}
  • What happens if you simply do \begin{figure}[t] ? – Peter Wilson Apr 11 '18 at 18:35
  • What exactly do you want to accomplish? (sorry if it's clear to everyone else, I personally am not sure what he wants) I understand the question that you don't want a figure to be placed at the top of the page, but at the bottom. Is that correct? Are there circumstances where you want a figure to be placed automatically at the top? If not, you could redefine the default figure placement to not include t, but only bp or hbp. – Skillmon Apr 11 '18 at 21:03
  • @Skillmon - I do NOT want the figure at the top of THIS page, but the top of the next page is fine. [ht] is a good approximation to what I am trying to accomplish. BTW, [b!t] seems to behave identical to [tb]. – John Kormylo Apr 11 '18 at 21:14
3

This solution converts every [b] figure to a [tb] figure at the end of every page. I'm not sure what all the bit flags do, but [t] is 50, [b] if 52 and [tb] is 54,

\documentclass{article}
\usepackage{lipsum}
\usepackage{everypage}

\makeatletter
\AddEverypageHook{%
  \def\reset#1{\ifnum\count#1=52 \global\count#1=54\fi}% convert [b] to [bt]
  \let\@elt=\reset
  \@deferlist}
\makeatother

\begin{document}
\lipsum[1-2]
\lipsum[3-4]% for op of next page

\begin{figure}[b]
\rule{\textwidth}{.2\textheight}
\caption{test}
\end{figure}

\lipsum[5-12]

\end{document}

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.