diff --git a/modules/images.xml b/modules/images.xml index b1482a8..21695a0 100644 --- a/modules/images.xml +++ b/modules/images.xml @@ -33,7 +33,7 @@ <!-- "Standard" scale image. For LaTeX, we simply pass off to the "latex-image" template above. --> - <template name="normal-image" match="image[count(provide-large-version) = 0]"> + <template name="normal-image" match="image[count(provide-large-version) = 0 and not(@inline)]"> <common> <!-- Check for obsolete child elements. We need to do this explicitly, as there isn't an apply-templates inside this template to pick them up automatically. @@ -120,6 +120,60 @@ <!-- + "Inline" image. These shouldn't be padded and should be about the same height as the text. 0.85em seems about right for (Xe)LaTeX, 1em with vertical-align middle for (X)HTML. Ideally only used for icons and the like. + --> + <template name="inline-image" match="image[@inline = 'yes']"> + <common> + <!-- + Check for obsolete child elements. We need to do this explicitly, as there isn't an apply-templates inside this template to pick them up automatically. + --> + <xsl:apply-templates select="basename|format|latex-scaling" /> + + <!-- + Check for existence of required attributes. For example, it doesn't really make sense for @basename to be missing. + --> + <xsl:if test="not( @basename )"> + <xsl:message terminate="yes"> + <xsl:text>ERROR: image element "</xsl:text> + <!-- Note that the description may be missing, which would make the error message less helpful :). --> + <xsl:value-of select="description" /> + <xsl:text>" missing required @basename attribute.</xsl:text> + </xsl:message> + </xsl:if> + </common> + <common formats="/latex/xelatex/"> + <xsl:text>\includegraphics</xsl:text> + <!-- + General-purpose latex pass-through arguments for \includegraphics. If providing multiple arguments, these should be comma-separated in the source XML, but do not need the enclosing square brackets. + --> + <xsl:text>[height=0.85em,keepaspectratio</xsl:text> + <xsl:if test="@latex-options"> + <xsl:text>,</xsl:text> + <xsl:value-of select="@latex-options" /> + </xsl:if> + <xsl:text>]</xsl:text> + <xsl:text>{</xsl:text> + <xsl:value-of select="infosci:build-image-path( @location, @basename, 'print', @format )" /> + <xsl:text>}</xsl:text> + </common> + <common formats="/html/xhtml/"> + <img style="padding: 0px; border-style: none; height: 1em; vertical-align: middle;"> + <xsl:attribute name="src"> + <xsl:value-of select="infosci:build-image-path( @location, @basename, 'web', @format )" /> + </xsl:attribute> + + <xsl:attribute name="alt"> + <xsl:apply-templates select="description" /> + <xsl:if test="not( description )"> + <xsl:value-of select="@basename" /> + </xsl:if> + </xsl:attribute> + </img> + </common> + </template> + + + <!-- Work out the full path specification for an image file to be included = base-path + location (if specified) + basename + suffix + format. With all arguments provided (see example values below), the result will look something like this: /base/path/images/an_image-print.pdf /base/path/images/an_image-web.png