From 29d28a9d46f9dab1a37a2bbafc612fe622a6b527 Mon Sep 17 00:00:00 2001 From: Andrew Scholer Date: Mon, 30 Jun 2025 14:20:42 -0700 Subject: [PATCH 1/6] Common: report width-native in layout-parameters --- xsl/pretext-common.xsl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xsl/pretext-common.xsl b/xsl/pretext-common.xsl index ffbd5a4b37..4e9544feee 100644 --- a/xsl/pretext-common.xsl +++ b/xsl/pretext-common.xsl @@ -5462,6 +5462,9 @@ Book (with parts), "section" at level 3 + + + - + @@ -5884,15 +5884,6 @@ along with MathBook XML. If not, see . - - - - - - - - - From e0b22b69bd517f84137068fd0221f7c95228d177 Mon Sep 17 00:00:00 2001 From: Andrew Scholer Date: Mon, 30 Jun 2025 14:40:29 -0700 Subject: [PATCH 3/6] HTML: image without width deisplayed at natural size if possible --- xsl/pretext-html.xsl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xsl/pretext-html.xsl b/xsl/pretext-html.xsl index ca63a89caa..348fb0696c 100644 --- a/xsl/pretext-html.xsl +++ b/xsl/pretext-html.xsl @@ -5862,7 +5862,13 @@ along with MathBook XML. If not, see . -
+
+ + image-box + + image-box__auto-width + + width: From 1249ccc817c59b205d1bd976d995546ad65c1a27 Mon Sep 17 00:00:00 2001 From: Andrew Scholer Date: Mon, 30 Jun 2025 14:41:24 -0700 Subject: [PATCH 4/6] CSS: style natural size images --- css/components/elements/_media.scss | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/css/components/elements/_media.scss b/css/components/elements/_media.scss index 4f20f7571c..0dda60e841 100644 --- a/css/components/elements/_media.scss +++ b/css/components/elements/_media.scss @@ -16,10 +16,20 @@ iframe.asymptote, // images in containers should grow to fit space .image-box img, -img.contained { +.image-box svg { width: 100%; } +.image-box.image-box__auto-width img, +.image-box.image-box__auto-width svg +{ + max-width: 100%; + width: auto; + margin-left: auto; + display: block; + margin-right: auto; +} + // --------------------------------------------- // images .ptx-content img, .ptx-content svg { From e692eacec95debccb1039702036638e7319a9d45 Mon Sep 17 00:00:00 2001 From: Andrew Scholer Date: Mon, 30 Jun 2025 14:41:55 -0700 Subject: [PATCH 5/6] Latex: images without width displayed at natural size if possible --- xsl/pretext-latex-common.xsl | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xsl/pretext-latex-common.xsl b/xsl/pretext-latex-common.xsl index a803112644..c3b6e2ad54 100644 --- a/xsl/pretext-latex-common.xsl +++ b/xsl/pretext-latex-common.xsl @@ -405,6 +405,7 @@ along with MathBook XML. If not, see . + @@ -1384,6 +1385,24 @@ along with MathBook XML. If not, see . + + + + %% Define maxwidth variable for includegraphics + %% recipe from https://texfaq.org/FAQ-grmaxwidth + \makeatletter + + \def\maxwidth{% + \ifdim\Gin@nat@width>\linewidth + \linewidth + \else + \Gin@nat@width + \fi + } + \makeatother + + + @@ -1391,7 +1410,7 @@ along with MathBook XML. If not, see . %% arguments are left-margin, width, right-margin, as multiples of %% \linewidth, and are guaranteed to be positive and sum to 1.0 \tcbset{ imagestyle/.style={bwminimalstyle} } - \NewTColorBox{tcbimage}{mmm}{imagestyle,left skip=#1\linewidth,width=#2\linewidth} + \NewTColorBox{tcbimage}{mmm}{imagestyle,left skip=#1\linewidth,width=#2\linewidth,halign=center} %% Wrapper environment for tcbimage environment with a fourth argument %% Fourth argument, if nonempty, is a vertical space adjustment %% and implies image will be preceded by \leavevmode\nopagebreak @@ -9294,7 +9313,15 @@ along with MathBook XML. If not, see . - \includegraphics[width=\linewidth + \includegraphics[width= + + + \linewidth + + + \maxwidth + + ,angle= From 0fe474202d242ee398fbec5a23b7ab5545888ce5 Mon Sep 17 00:00:00 2001 From: Andrew Scholer Date: Mon, 7 Jul 2025 13:43:46 -0700 Subject: [PATCH 6/6] Sample Article: update graphics samples with width options --- .../media/images/new-folder-screenshot.png | Bin 0 -> 7291 bytes examples/sample-article/sample-article.xml | 23 +++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 examples/sample-article/media/images/new-folder-screenshot.png diff --git a/examples/sample-article/media/images/new-folder-screenshot.png b/examples/sample-article/media/images/new-folder-screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..7f20d364f468e37ad231d8fcde8ea1f9fee6496f GIT binary patch literal 7291 zcmZ`;by!s2)+VK-O95$QXr!b^x+I3~5FAjDMtTq=2LwdA8A=Ih5RmSnOS((CgkfO7 zZ}{DNpYQ(heb4irGqd;E=UMCQv)22rvv-t^mI^T;9U%q=2C^*UlaeE}oVK_~={c&(sv<^nEN3vwZdS`tI71U4B{;(>qns zI3<5>WB6*dZvtem19U54G^IaubG|y%aT9+3u^LW|=^Y*NqwcMl_rC6aCk*z>bibDo z-;VU_>PSMowet~bWN2~G++FT`^%~#CT{ePJU@;@@H~=WT(x?{8kEzg0#_$Can%uwo z7eAT^D2yMP98%6W5~=Y*N42IST0HngWk+F>lCFMNm01KU z+g39apzhEyySElYrbK`f(OdX;tP1CWr6+zUI0AiT;Dllx$qc2yC;2q^A#Vf!5#&Et zI!-9(k*<#goftag)?TycQOi?tkl}>w7*n$Rd$`R;2I;~tGJG8RbR!T}UexT<+VeFb z*I6H|@aHHT`Evy-j#}$0g2R9x4;f^$+uH{*u=3{aZw~47D2qaOGOAa$6Fmdn>l+n<%pAt7Y_WHY{C|@OpNo2>e@cPEL}@wj=?Yc zA|GDar+Kq?~xIbjts(8dHVOmqxZvmoCmbtmp0)NN(CChPk3c6E&G3rqxQ+} z5aKG}rU2Pj@{}FHUu6VB)B-GVzN8M=BGN?=>H27p29`v~_9*0Bf8YBm?%A0#)cEt4 zICB_YPfX^Um>e&bY2JKockE*Wic%oB!bY|V`r*h?B^ z9qRfPY4oJ=Qx`W&ODz?y*V^~I8MSYd&(1yzxGvrKqL;0$-GbPp9qnuTX}?wxr*&u0 zH0nRU`5ASIAN?nHR=2CBCQeHDMljIsDf5%i-HqMhzYntnn=E^6<;f2y8QJ<`ww{Nd zSg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AyFSHg_Qno6px+;F4YuTGNXK&tE;H6ny5kzJH{58bFeq+cPwJf>Q<;6SDeMRu zj|N?hn4P_NUWMqZV4XSrWd5_Ewua-$io1dt)vV^F#4**Zm3Gy0E>Bz>V#D8J9E6q9 z9AP!kR!?3@*r%61bdvG1%@z@JV)+A7`_x4_El|^C++eWZ#Yu;Et#r@wEPqV#tl7cs zGymtR=<{OYOxTi|hXCO6?$O7;QE_Om;Vt5=vi?u*qN^+VTX8#&l_=#JqOaH9&(9_J ztz~y!&XnRcTClS_g?I%JmGo>C+IGYWc<0hfMgxC$-rHOEB7GhfnDPxxXTO!jupv@YBr+ z8?of-Z+fPChxg7o>qKR*aHI1H(H$q{RnVwR^o@NdNns0mYbO*O{BH@AcgzceAU~t` zn5b(P1%MPv1mz*gH(M$&KnJoTXC~0g3R2eKPD6O#-esaXgSMfr{2x~QSC4ud%GhO# z7yaoLa&DXdb=3-D2lUlKD=yu~Pq2_6WYxxkv!zS`T3zKg-b7hJy3rDhwsEzk@(`3b u#_jNbbmdt=*wJ3blKlU={9h7|3<}G9uij)9+k)O3#86YxQv5D&9r8bJzB66` literal 0 HcmV?d00001 diff --git a/examples/sample-article/sample-article.xml b/examples/sample-article/sample-article.xml index 07af90cb74..6287889731 100644 --- a/examples/sample-article/sample-article.xml +++ b/examples/sample-article/sample-article.xml @@ -3306,6 +3306,23 @@ along with MathBook XML. If not, see . +

Images that are given a width (always as a percentage) are scaled to that percentage of their container. Images without a width will be rendered at their natural size if possible and as large as possible if not. This can be seen in these three renderings of the same screenshot:

+ +
+ A new folder with width="100%" + +
+ +
+ A new folder with width="50%" + +
+ +
+ A new folder with no width + +
+

If you have existing images that are vector graphics, then PDF format works best for output and SVG format works best for HTML. The utility pdf2svg works well for converting PDF to SVG. In this case, specify your source as a filename, but leave off the file extension, and the appropriate version will be used for the current output format.

The image below is provided from a PDF file in output, and was converted to an SVG for use with the HTML output. It has been explicitly scaled to a width of 65% of the text width.

@@ -3347,7 +3364,7 @@ along with MathBook XML. If not, see .
Solution to a differential equation - + @@ -3375,7 +3392,7 @@ along with MathBook XML. If not, see .

This next diagram employs some macros that are defined in the usual way in docinfo and are employed to produce the names of some vectors in the labels. The blue line is colored blue by a global declaration, also in docinfo.

- + @@ -3418,7 +3435,7 @@ along with MathBook XML. If not, see .

The next diagram is authored with annotations, arranged in a hierarchy of increasing refinement and detail. Each identified graphical component will read its annotation and show it on the screen below the diagram. When a reader clicks on the image, a high-level summary will be read using the author-provided annotation. The down and up arrow keys enable a reader to explore the diagram in more or less detail while the right and left arrow keys reveal features at the same level of detail. When the focus is on the graph, pressing "O" will produce a sonification of the graph.

- +