Skip to content

Commit

Permalink
Liberalize specification of "extra" LaTeX packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rbeezer committed Oct 18, 2023
1 parent 7dbd604 commit 16ab3b7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
11 changes: 0 additions & 11 deletions xsl/pretext-common.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1466,17 +1466,6 @@ Book (with parts), "section" at level 3
<!-- LaTeX Preamble -->
<!-- ############## -->

<!-- We round up any author-supplied packages as -->
<!-- a big string, in LaTeX syntax. It will need -->
<!-- manipulation to be usable on the MathJax side -->
<xsl:variable name="latex-packages">
<xsl:for-each select="$docinfo/latex-preamble/package">
<xsl:text>\usepackage{</xsl:text>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
</xsl:for-each>
</xsl:variable>

<!-- We pick up user-supplied macros, and -->
<!-- add three of our own that are useful -->
<!-- for avoiding conflicts with XML reserved -->
Expand Down
12 changes: 10 additions & 2 deletions xsl/pretext-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12981,10 +12981,18 @@ TODO:
<!-- First a variable to massage the author-supplied -->
<!-- package list to the form MathJax expects -->
<xsl:variable name="latex-packages-mathjax">
<xsl:value-of select="str:replace($latex-packages, '\usepackage{', '\require{')" />
<xsl:for-each select="$docinfo/math-package">
<!-- must be specified, but can be empty/null -->
<xsl:if test="not(normalize-space(@mathjax-name)) = ''">
<xsl:text>\require{</xsl:text>
<xsl:value-of select="@mathjax-name"/>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
<!-- all on one line, not very readable, but historical -->
</xsl:if>
</xsl:for-each>
</xsl:variable>


<!-- MathJax expects math wrapping, and we place in -->
<!-- a hidden div so not visible and take up no space -->
<!-- Inline CSS added because a "flash" was visible -->
Expand Down
25 changes: 21 additions & 4 deletions xsl/pretext-latex.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -1824,10 +1824,27 @@ along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
<xsl:value-of select="$latex.preamble.late" />
<xsl:text>&#xa;</xsl:text>
</xsl:if>
<xsl:text>%% Begin: Author-provided packages&#xa;</xsl:text>
<xsl:text>%% (From docinfo/latex-preamble/package elements)&#xa;</xsl:text>
<xsl:value-of select="$latex-packages" />
<xsl:text>%% End: Author-provided packages&#xa;</xsl:text>
<!-- "extra" packages specified by the author -->
<xsl:variable name="latex-packages">
<xsl:for-each select="$docinfo/math-package">
<!-- must be specified, but can be empty/null -->
<xsl:if test="not(normalize-space(@latex-name)) = ''">
<xsl:text>\usepackage{</xsl:text>
<xsl:value-of select="@latex-name"/>
<xsl:apply-templates />
<xsl:text>}</xsl:text>
<!-- one per line for readability -->
<xsl:text>&#xa;</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:if test="not($latex-packages = '')">
<xsl:text>%% Begin: Author-provided TeX/LaTeX packages&#xa;</xsl:text>
<xsl:text>%% (From docinfo/math-package elements)&#xa;</xsl:text>
<xsl:value-of select="$latex-packages"/>
<xsl:text>%% End: Author-provided TeX/LaTeX packages&#xa;</xsl:text>
</xsl:if>
<!-- "extra" macros specified by the author -->
<xsl:text>%% Begin: Author-provided macros&#xa;</xsl:text>
<xsl:text>%% (From docinfo/macros element)&#xa;</xsl:text>
<xsl:text>%% Plus three from PTX for XML characters&#xa;</xsl:text>
Expand Down

0 comments on commit 16ab3b7

Please sign in to comment.