Here is my XSL for margin figures and friends. There are a couple of
other bits of XSL to reset widths for images and tabulars in the margin
that aren't affected by the change.
I tried wrapping some of this up into a \mfigure macro that I defined in
the latex-preamble-late but every attempt I made resulted in the
compiler choking on page numbers not being defined yet. The initial
comment is there because I'll need to comb through the .tex source to
set the vertical placement for each figure.
<xsl:template match="figure[not(ancestor::sidebyside) and
not(ancestor::aside) and not(descendant::sidebyside) and
(descendant::latex-image or descendant::asymptote or
descendant::tabular) and not(ancestor::exercise)]">
<xsl:text>%% margin figure %%
</xsl:text>
<xsl:text>\AddToShipoutPicture*{\put(427,\LenToUnit{0.5\paperheight}){%
</xsl:text>
<xsl:text>\begin{minipage}{\marginparwidth}
</xsl:text>
<xsl:text>\begin{</xsl:text>
<xsl:apply-templates select="." mode="environment-name"/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="." mode="caption-full"/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="." mode="latex-id"/>
<xsl:text>}{</xsl:text>
<xsl:if test="$b-latex-hardcode-numbers">
<xsl:apply-templates select="." mode="number"/>
</xsl:if>
<xsl:text>}%
</xsl:text>
<!-- images have margins and widths, so centering not needed -->
<!-- Eventually everything in a figure should control itself -->
<!-- or be flush left (or so) -->
<xsl:if test="self::figure and not(image)">
<xsl:text>\centering
</xsl:text>
</xsl:if>
<xsl:apply-templates select="*"/>
<!-- reserve space for the caption -->
<xsl:text>\tcblower
</xsl:text>
<xsl:text>\end{</xsl:text>
<xsl:apply-templates select="." mode="environment-name"/>
<xsl:text>}%
</xsl:text>
<xsl:apply-templates select="." mode="pop-footnote-text"/>
<xsl:text>\end{minipage}}}
</xsl:text>
<xsl:text>\par
</xsl:text>
</xsl:template>
On 2021-07-19 12:36 p.m., Rob Beezer wrote: