Skip to content
Open
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
2 changes: 1 addition & 1 deletion skills/minimax-pdf/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ You have creative authority over the accent color. Pick it from the document's s
| `bullet` | Unordered list item (• prefix) | `text` |
| `numbered` | Ordered list item — counter auto-resets on non-numbered blocks | `text` |
| `callout` | Highlighted insight box with accent left bar | `text` |
| `table` | Data table — accent header, alternating row tints | `headers`, `rows`, `col_widths`?, `caption`? |
| `table` | Data table — accent header, alternating row tints | `headers`, `rows`, `col_widths`?, `caption`? | `col_widths` is a list of **fractions summing to 1.0** (e.g. `[0.3, 0.5, 0.2]`). Absolute widths in PDF points are also accepted as a fallback and will be clamped to the page width. | `col_widths` is a list of **fractions summing to 1.0** (e.g. `[0.3, 0.5, 0.2]`). Absolute widths in PDF points are also accepted as a fallback and will be clamped to the page width. |
| `image` | Embedded image scaled to column width | `path`/`src`, `caption`? |
| `figure` | Image with auto-numbered "Figure N:" caption | `path`/`src`, `caption`? |
| `code` | Monospace code block with accent left border | `text`, `language`? |
Expand Down
23 changes: 21 additions & 2 deletions skills/minimax-pdf/scripts/render_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,28 @@ def _add_table(story: list, item: dict, ctx: dict):
]
n_cols = len(item["headers"])

# Optional col_widths as fractions summing to 1.0
# Optional col_widths. Two formats accepted, auto-detected:
# - Fractions summing to ~1.0 (e.g. [0.3, 0.5, 0.2]) — multiplied by usable_w
# - Absolute widths in PDF points (e.g. [120, 200, 80]) — used as-is, clamped to usable_w
if "col_widths" in item and len(item["col_widths"]) == n_cols:
col_w = [usable_w * f for f in item["col_widths"]]
widths = [float(f) for f in item["col_widths"]]
s = sum(widths)
all_unit_or_less = all(0 <= w <= 1.0 for w in widths)
if abs(s - 1.0) < 0.01 and all_unit_or_less:
# Fractions format
col_w = [usable_w * f for f in widths]
else:
# Absolute widths in points — clamp each to fit within usable_w
col_w = [min(w, usable_w) for w in widths]
# If the sum still exceeds usable_w, scale down proportionally
total = sum(col_w)
if total > usable_w:
col_w = [w * (usable_w / total) for w in col_w]
sys.stderr.write(
f"[minimax-pdf] table col_widths on page treating as absolute "
f"points (sum={s:.1f}); fractions summing to 1.0 are recommended. "
f"See references/design.md.\n"
)
else:
col_w = [usable_w / n_cols] * n_cols

Expand Down