0

I'm currently working on a twoside,twocolumns document and have a certain float (covering the entirety of a column) which, for aestetic purposes, should only go on an outer column; so first column on even pages, second column on odd pages.

So far I've tried controlling its position through controlling when it's first seen through afterpage, which kinda works but is far from consistent.

Suthek
  • 189

1 Answers1

1

Yup, it works.

\documentclass[twocolumn]{report}
\usepackage{lipsum}% MWE only

\makeatletter
\def\@floatplacement{\if@firstcolumn
  \global\@topnum=0
  \global\@botnum=0
  \@fpmin=2\@colht
\else
  \global\@topnum=\c@topnumber
  \global\@botnum=\c@bottomnumber
  \@fpmin=\floatpagefraction\@colht
\fi
\global\@toproom=\topfraction\@colht
\global\@botroom=\bottomfraction\@colht
\global\@colnum=\c@totalnumber}
\makeatother

\begin{document}
\begin{figure}[tb]
  \caption{Test Figure}
\end{figure}

\begin{table}[tb]
  \caption{Test Table}
\end{table}

\begin{figure}[p]
  \centering
  \rule{.9\columnwidth}{.9\textheight}
\end{figure}

\lipsum[1-10]
\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • I've experimentally implemented that yesterday as well, and it does work. My issue since yesterday, however, is: This'll affect all single-column tb floats, not just the one type I want fixed on the outer columns. At the moment there aren't any, so this solution is sufficient for the time being, but that may change. Using [tb!] as you commented is indeed a workaround for that issue, but I'm worried that it carries other problems with it (given that it ignores all restrictions, not just this one). – Suthek Jan 10 '20 at 17:34
  • The float options are reduced to bit flags, so creating a new one would affect an awful lot of code. – John Kormylo Jan 10 '20 at 17:38
  • Is there maybe a way to handle it through a new float type vs. a new placement option? I'm not sure which function handles the decision if a current float can be placed somewhere, but could it be altered to take additional restrictions if float type is X; or is that too deep into the core? – Suthek Jan 10 '20 at 17:53
  • I believe you are right. The float type is packed into the same count register as the bit flags. So the information is there, but obviously @floatplacement won't handle it. BTW, the queue consists of a macro delimited list (fancy). – John Kormylo Jan 11 '20 at 02:22
  • The most I've ever attempted was in https://tex.stackexchange.com/questions/425892/place-figure-at-bottom-of-this-page-or-the-top-of-the-next-page/426250?r=SearchResults&s=2|39.5185#426250 – John Kormylo Jan 11 '20 at 02:26
  • I'll accept your answer as it solves the issue as posted and it did ultimately help me solve the issue more specifically. I was able to take advantage of the fact that the float in question is the only one that takes up a whole column by its own, so instead of manipulating @topnum and @botnum I altered @fpmin, @textmin, @toproom & @botroom in the relevant columns so this particular float simply won't fit into the inner columns. Thanks. – Suthek Jan 11 '20 at 13:19