Skip to content

Commit 1e15c3e

Browse files
JihaoXinclaude
andcommitted
Remove FloatBarrier injection, add figure placement rules to writer prompt
FloatBarrier approach was too rigid — figures piling up on a blank page before References. Instead, writer agent is now responsible for checking figure placement after every edit: - No blank pages with only figures - No figures after the last section - Figures appear near their reference context - Multi-panel figures use figure* in multi-column templates Writer prompt: added "Figure Placement Rules" section with concrete fixes (move figure earlier, reduce height, use [!htbp], etc.) Reverted _ensure_clearpage_before_bibliography to simple \clearpage only. Cleaned up euromlsys template (removed placeins/FloatBarrier). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f563de7 commit 1e15c3e

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

ark/execution.py

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -725,54 +725,30 @@ def _enforce_page_count(self, context: str = "post-writing") -> bool:
725725
return True
726726

727727
def _ensure_clearpage_before_bibliography(self):
728-
"""Ensure \\FloatBarrier + \\clearpage before \\bibliography in main.tex.
728+
"""Ensure \\clearpage before \\bibliography in main.tex.
729729
730-
FloatBarrier forces all pending figures to be placed within the body
731-
(prevents them from floating past References). clearpage starts a new
732-
page for References. Both are injected programmatically.
730+
This guarantees References starts on a new page, separate from body.
733731
"""
734732
main_tex = self.latex_dir / "main.tex"
735733
if not main_tex.exists():
736734
return
737735
try:
738736
content = main_tex.read_text()
739-
changed = False
740-
741-
# Ensure \usepackage{placeins} is in preamble (for \FloatBarrier)
742-
if r'\usepackage{placeins}' not in content:
743-
# Insert after last \usepackage line in preamble
744-
import re
745-
last_pkg = list(re.finditer(r'\\usepackage(\[.*?\])?\{.*?\}', content))
746-
if last_pkg:
747-
insert_pos = last_pkg[-1].end()
748-
content = content[:insert_pos] + '\n\\usepackage{placeins}' + content[insert_pos:]
749-
changed = True
750-
751737
marker = r'\bibliography{'
752738
if marker not in content:
753739
return
754-
755-
# Build the correct pre-bibliography block
756-
pre_bib = '\\FloatBarrier\n\\clearpage\n'
757-
758-
# Check if already correct
759-
if pre_bib + marker in content:
760-
if changed:
761-
main_tex.write_text(content)
762-
return
763-
764-
# Remove any existing partial insertions and rebuild
740+
# Clean up any old FloatBarrier injections
765741
content = content.replace('\\FloatBarrier\n\\clearpage\n' + marker, marker)
766742
content = content.replace('\\FloatBarrier\n' + marker, marker)
767-
content = content.replace('\\clearpage\n' + marker, marker)
768-
content = content.replace('\\clearpage\n\n' + marker, marker)
769-
770-
# Insert FloatBarrier + clearpage before bibliography
771-
content = content.replace(marker, pre_bib + marker)
743+
# Check if \clearpage already precedes \bibliography
744+
if '\\clearpage\n' + marker in content or '\\clearpage\n\n' + marker in content:
745+
return
746+
# Insert \clearpage before \bibliography
747+
content = content.replace(marker, '\\clearpage\n' + marker)
772748
main_tex.write_text(content)
773-
self.log("Injected \\FloatBarrier + \\clearpage before \\bibliography", "INFO")
749+
self.log("Injected \\clearpage before \\bibliography", "INFO")
774750
except Exception as e:
775-
self.log(f"Failed to inject FloatBarrier/clearpage: {e}", "WARN")
751+
self.log(f"Failed to inject \\clearpage: {e}", "WARN")
776752

777753
def _run_writing_phase(self, action_plan: dict, prior_context: str = ""):
778754
"""Execute writing phase for all writing tasks."""

ark/templates/agents/writer.prompt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ The paper body (excluding references and appendix) has a strict page target:
6262

6363
**Always ensure `\clearpage` appears before `\bibliography`** so references start on a new page.
6464

65+
## Figure Placement Rules (MUST check after every edit)
66+
67+
After every modification, compile and check that:
68+
1. **No blank pages with only figures** — if a figure can't fit on the current page, it may float to a later page. If this creates a page with only figure(s) and no text, fix it by:
69+
- Moving the `\begin{figure}` declaration earlier in the text
70+
- Reducing figure height with `\includegraphics[width=...,height=...]`
71+
- Using `[!htbp]` placement specifier instead of `[t]`
72+
2. **No figures after the last section** — all figures must appear within or between body sections, never between the last section and `\clearpage`/References
73+
3. **Figures match their context** — a figure referenced in Section 3 should appear on or near Section 3's pages, not 2 pages later
74+
4. **Multi-panel figures use correct environment** — figures with 2+ panels (side-by-side) should use `\begin{figure*}` (full width) in multi-column templates, so fonts are readable
75+
76+
If you see layout issues after compiling, fix them before finishing.
77+
6578
**Compression strategies** (in order of priority):
6679
1. Move detailed ablations, sensitivity analyses, and per-category breakdowns to `\appendix`
6780
2. Merge Discussion and Conclusion into one section

venue_templates/euromlsys/main.tex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
\renewcommand\footnotetextcopyrightpermission[1]{}
55
\pagestyle{plain}
66

7-
\usepackage{placeins}
8-
97
\begin{document}
108

119
\title{Paper Title}
@@ -32,7 +30,6 @@ \section{Experiments}
3230

3331
\section{Conclusion}
3432

35-
\FloatBarrier
3633
\clearpage
3734
\bibliographystyle{ACM-Reference-Format}
3835
\bibliography{references}

0 commit comments

Comments
 (0)