Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX calculates the required space for floats incorrectly in some circumstances #1645

Open
FrankMittelbach opened this issue Jan 28, 2025 · 0 comments
Assignees
Labels
bug category base (latex) fixed in dev Fixed in development branch, not in stable release

Comments

@FrankMittelbach
Copy link
Member

Brief outline of the bug

When LaTeX calculates the space requirements for floats it does so incorrectly if the float doesn't fit into the first area it tries. In the second and third area it adds additional space (from \textfloatsep or \floatsep) without removing \intextsep again. Thus, there are cases when a [t] fits but the same float as [ht] doesn't fit. Same, but less likely a problem: when [b] by its own fits [tb]or [hb] may not fit.

Minimal example showing the bug

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}

 \setlength\intextsep{50pt}
\renewcommand\topfraction{.7}
\renewcommand\bottomfraction{.7}

\usepackage{fltrace}

\tracefloatvals

\tracefloats

\begin{document}

aaa\par aaa\par aaa\par aaa\par aaa\par aaa\par  
aaa\par aaa\par aaa\par aaa\par aaa\par aaa\par 
aaa\par aaa\par aaa\par aaa\par aaa\par aaa\par 
aaa\par aaa\par aaa\par aaa\par aaa\par aaa\par 

\begin{figure}[htb]
  1\rule{2cm}{8cm}
\end{figure}

bbb\par bbb\par bbb\par bbb\par bbb\par bbb\par 
bbb\par bbb\par bbb\par bbb\par bbb\par bbb\par 
bbb\par bbb\par bbb\par bbb\par bbb\par bbb\par 
bbb\par bbb\par bbb\par bbb\par bbb\par bbb\par 
bbb\par bbb\par bbb\par bbb\par bbb\par bbb\par 
\end{document}

Log file (required) and possibly PDF file

Relevant portion of the log \@reqcolroom should not change from one test to the next:

LaTeX2e: ***Start addtocurcol
LaTeX2e: (mod 32) fpstype: 23
LaTeX2e: (mult of 32) currtype: 32
LaTeX2e: ORD float
LaTeX2e: fpstype: 23(flsettextmin)
LaTeX2e: ORD textmin = 109.99832pt
LaTeX2e: textfloatsheight (before) = 0.0pt
LaTeX2e: textmin + textfloatsheight: 109.99832pt
LaTeX2e: page-so-far: 286.0pt
LaTeX2e: float size = 227.62204pt(addtocurcol)
LaTeX2e: colroom = 550.0pt(addtocurcol)
LaTeX2e: reqcolroom = 513.62204pt(addtocurcol)
LaTeX2e: fpstype: 23(flsetnum \@colnum)
LaTeX2e: \@colnum  (before) = 3
LaTeX2e: \@currbox single column float -- ok
LaTeX2e: deferlist: : (addtocurcol-before)
LaTeX2e: botlist: : (addtocurcol-before)
LaTeX2e: fpstype OK here: 23
LaTeX2e: Fail---no room at 2nd test of colroom (addtocorcol \intextsep)
LaTeX2e: not here: sent to addtotoporbot
LaTeX2e: ***Start addtotoporbot
LaTeX2e: fpstype OK top: 23
LaTeX2e: fpstype: 23(flsetnum \@topnum)
LaTeX2e: \@topnum  (before) = 2
LaTeX2e: colroom = 550.0pt(flcheckspace \@toproom \@toplist)
LaTeX2e: reqcolroom = 583.62204pt(flcheckspace \@toproom \@toplist)
LaTeX2e: Fail---no room at 2nd test of colroom (flcheckspace \@toproom \@toplis
t)
LaTeX2e: sent to addtobot (addtotoporbot)
LaTeX2e: ***Start addtobot
LaTeX2e: fpstype OK bot: 23
LaTeX2e: fpstype: 23(flsetnum \@botnum)
LaTeX2e: \@botnum  (before) = 1
LaTeX2e: colroom = 550.0pt(flcheckspace \@botroom \@botlist)
LaTeX2e: reqcolroom = 603.62204pt(flcheckspace \@botroom \@botlist)
LaTeX2e: Fail---no room at 2nd test of colroom (flcheckspace \@botroom \@botlis
t)
LaTeX2e: put on deferlist (addtocurcol)
LaTeX2e: deferlist: \bx@A : (addtocurcol-after)
@FrankMittelbach FrankMittelbach added this to the Release 2025 Q2 milestone Jan 28, 2025
@FrankMittelbach FrankMittelbach self-assigned this Jan 28, 2025
@github-project-automation github-project-automation bot moved this to Pool (unscheduled issues) in upcoming LaTeX2e releases Jan 28, 2025
FrankMittelbach added a commit that referenced this issue Jan 29, 2025
FrankMittelbach added a commit that referenced this issue Jan 31, 2025
* fix for #1645 (WIP)

* update some tlgs

* more tlgs

* grummel

* changelog, internal rename, ltnews41

* small editorial changes

* typo

* fix typos; added another test for rollback

* add another test and correct previous one

* overlooked one suggestion
@FrankMittelbach FrankMittelbach added the fixed in dev Fixed in development branch, not in stable release label Feb 1, 2025
@FrankMittelbach FrankMittelbach moved this from Pool (unscheduled issues) to Done in dev in upcoming LaTeX2e releases Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category base (latex) fixed in dev Fixed in development branch, not in stable release
Projects
Status: Done in dev
Development

No branches or pull requests

1 participant