Accept columnwidth and paper dimensions in graphics options

parse_image_length only recognized \textwidth, \linewidth, \hsize, \textheight
and \vsize, so width=\columnwidth (common in two-column templates) produced no
size. The list now also accepts \columnwidth and \paperwidth as widths and
\paperheight as a height, each scaling the configured measure.

The graphics sizing test gains a width=0.5\columnwidth case matching the
\textwidth result.
This commit is contained in:
gloamxun committed 2026-10-27 03:38:44 +08:00
1 parent f5ddad30a2
commit 82c3e24d18
2 files changed
+5 -1

No files matched your search

+4
View File
@@ -8210,8 +8210,11 @@ fn parse_image_length(value: &str) -> Option<ImageLength> {
for (suffix, height) in [
("\\textwidth", false),
("\\linewidth", false),
("\\columnwidth", false),
("\\paperwidth", false),
("\\hsize", false),
("\\textheight", true),
("\\paperheight", true),
("\\vsize", true),
] {
if let Some(factor) = value.strip_suffix(suffix) {
@@ -14629,6 +14632,7 @@ mod source_tests {
);
let cases = [
("width=0.5\\textwidth", (240 * SCALE, 120 * SCALE)),
("width=0.5\\columnwidth", (240 * SCALE, 120 * SCALE)),
(
"width=100pt,height=100pt,keepaspectratio",
(100 * SCALE, 50 * SCALE),