Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/tutorials/figure-positioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ As shown in @fig:results A, the data indicates...
{#fig:schematic tex_position="p" width="\textwidth"}
```

When `width="\textwidth"` is used with `tex_position="p"`, Rxiv-Maker creates a
`figure*` environment to span the full page width, preventing captions from
overflowing in two-column layouts. If the figure floats too far from the
reference point, insert `<clearpage>` or `<float-barrier>` before the figure to
force placement.

## Figure File Organization

### Ready Figures (Recommended)
Expand Down Expand Up @@ -120,6 +126,8 @@ FIGURES/
### Figure Appears on Wrong Page
- Try `tex_position="!t"` to force top placement
- For large figures, use `tex_position="p"` for dedicated page
- Insert `<clearpage>` or `<float-barrier>` before the figure to keep it near
the reference point when using `tex_position="p"`

### Figure Too Large
- Reduce `width` parameter: `width="0.7\linewidth"`
Expand Down
16 changes: 12 additions & 4 deletions src/rxiv_maker/converters/figure_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,23 @@ def create_latex_figure_environment(

# Handle new subdirectory structure: Figure__name.svg -> Figure__name/Figure__name.png
if "/" not in latex_path.split("Figures/")[-1]: # Only if not already in subdirectory
# Extract figure name from path like "Figures/Figure__name.svg"
import os
from pathlib import Path

# Extract figure name from path like "Figures/Figure__name.svg"
figure_name = os.path.splitext(os.path.basename(latex_path))[0]
figure_ext = os.path.splitext(latex_path)[1]

# Check if figure already exists as ready file (direct in Figures/ directory)
ready_figure_path = latex_path
if os.path.exists(ready_figure_path.replace("Figures/", "FIGURES/")):
ready_figure_path = latex_path.replace("Figures/", "FIGURES/")

# Resolve against manuscript path when available to avoid false negatives
manuscript_root = os.getenv("MANUSCRIPT_PATH")
ready_figure_fullpath = (
Path(manuscript_root) / ready_figure_path if manuscript_root else Path(ready_figure_path)
)

if ready_figure_fullpath.exists():
# Ready figure exists, use it directly without subdirectory conversion
# latex_path already contains the correct ready file path
pass
Expand Down Expand Up @@ -192,7 +200,7 @@ def create_latex_figure_environment(
attributes.get("span") == "2col"
or attributes.get("twocolumn") == "true"
or attributes.get("twocolumn") is True
or (width == "\\textwidth" and position != "p") # Auto-detect, but not for dedicated page figures
or width == "\\textwidth" # Auto-detect full-width figures regardless of position
)

# Only adjust positioning for two-column spanning figures that don't have explicit positioning
Expand Down