Maintaining slides inside an article

21 views
Skip to first unread message

Stephen Flood

unread,
Jul 10, 2024, 2:39:12 PMJul 10
to PreTeXt support
I am trying to create a large number of slides for a class I will be teaching, and I am hoping to create a single PreTeXt document where I can work on them. 

My current plan is to
1. Create a separate .ptx file for each section. 
2. When I want to compile as slides, to import the relevant section into a <slideshow> environment in my main.ptx file
3. When I want to see everything at once, to have the sections imported into a <book> environment in my main.ptx , with chapters dividing the ptx (section) files appropriately
4. In the main.ptx file, to comment out the outer environment (slideshow/book) I am not currently using.

Without any modifications, this builds the html output, but with errors like the following
   * PTX:ERROR:   An object (slide) lacks a serial number, search output for "[NUM]"
    *              located within: "What This Is" (title)
    * PTX:ERROR:   An object (slide) lacks a structure number, search output for "[STRUCT]"
    *              located within: "What This Is" (title)

I tried fiddling around with the xsl, and I was able to manage to get the errors to go away, but it doesn't number, or even bold, the title.

Ideally, I would like a way to just instruct PreTeXt to treat a "slide" as something like a "Remark" or an "Example" when it is being compiled to HTML.  Is there an elegant way to do this?  Is there an alternate strategy that will work better?
 

Sean Fitzpatrick

unread,
Jul 10, 2024, 3:28:13 PMJul 10
to pretext...@googlegroups.com

Probably there are two problems:

1. There is no xml:id on the slides, or maybe it's just that slides aren't numbered

2. The slide object isn't supported as a child of a book or article, only a slideshow

I don't think there's a way to do both at once


--
You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/4a106a0d-2d7c-4ce1-87ad-de4df16f032bn%40googlegroups.com.

Stephen Flood

unread,
Jul 10, 2024, 4:20:26 PMJul 10
to PreTeXt support
Thanks for your help with this.  Adding the xml:id didn't change the issue, I think you're probably right that slides are not numbered.

I know that <slide> as an element of <book> is not officially supported, and I don't think it makes sense to keep the slides all together in a book for the long term.  I'll just go crazy if I need to keep going between a dozen different PreTeXt documents as I try to put them together, and a nice feature of PreTeXt is it lets the reader easily switch between focusing on the big and small picture. 

My hope was to create an xsl file to extend the pretext-html.xsl that would help with this use case. 

Playing around with pretext-html.xsl, I have found that the following file causes the numbering errors to go away, but it no longer formats the titles of the slides as bold.  I found both blocks of code by searching pretext-html.xsl for "paragraphs", since they are un-numbered. 

I've tried copying all the rows where the match includes "paragraphs" and changing it to match="slides".  Is there more going on behind the scenes than I realize? 
 
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:import href="./core/pretext-html.xsl"/>

   
    <xsl:template match="slide">
       
        <xsl:param name="b-original" select="true()" />
        <xsl:variable name="hidden">
            <xsl:apply-templates select="." mode="is-hidden" />
        </xsl:variable>
        <xsl:choose>
            <!-- born-hidden case -->
            <xsl:when test="$hidden = 'true'">
                <xsl:apply-templates select="." mode="born-hidden">
                    <xsl:with-param name="b-original" select="$b-original" />
                </xsl:apply-templates>
            </xsl:when>
            <!-- born-visible case -->
            <xsl:otherwise>
                <!-- pass-thru of b-original mandatory -->
                <xsl:apply-templates select="." mode="born-visible">
                    <xsl:with-param name="b-original" select="$b-original" />
                </xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

   
<!-- All of the implementations above use the same   -->
<!-- template for their body, it relies on various   -->
<!-- templates but most of the work comes via the    -->
<!-- "wrapped-content" template.  Here is that       -->
<!-- "body" template.  The items in the "match"      -->
<!-- are in the order presented above: simple first, -->
<!-- and top-down when components are also knowled.  -->


    <xsl:template match="paragraphs" mode="body">
        <xsl:param name="b-original" select="true()"/>
        <xsl:param name="block-type"/>

        <!-- prelude beforehand, when original -->
        <xsl:if test="$b-original">
            <xsl:apply-templates select="prelude">
                <xsl:with-param name="b-original" select="$b-original" />
            </xsl:apply-templates>
        </xsl:if>
        <xsl:variable name="body-elt">
            <xsl:apply-templates select="." mode="body-element" />
        </xsl:variable>
        <xsl:element name="{$body-elt}">
            <xsl:attribute name="class">
                <xsl:apply-templates select="." mode="body-css-class" />
                <xsl:if test="$block-type = 'hidden'">
                    <xsl:text> knowl__content</xsl:text>
                </xsl:if>
            </xsl:attribute>
            <!-- Label original, but not if embedded            -->
            <!-- Then id goes onto the knowl text, so locatable -->
            <xsl:if test="$b-original and not($block-type = 'hidden')">
                <xsl:apply-templates select="." mode="html-id-attribute"/>
                <xsl:apply-templates select="." mode="permid-attribute"/>
            </xsl:if>
            <!-- If visible, heading interior to article -->
            <xsl:if test="$block-type = 'visible'">
                <xsl:apply-templates select="." mode="heading-birth" />
            </xsl:if>
            <!-- If xref-knowl, heading interior to article -->
            <xsl:if test="$block-type = 'xref'">
                <xsl:apply-templates select="." mode="heading-xref-knowl" />
            </xsl:if>
            <!-- After the heading, and before the actual guts, we      -->
            <!-- sometimes annotate with a knowl showing the source     -->
            <!-- of the current element.  This calls a stub, unless     -->
            <!-- a separate stylesheet is used to define the template,  -->
            <!-- and the method is defined there.  An "fn" necessarily  -->
            <!-- comes through here since it is realized as a knowl,    -->
            <!-- but it is a silly thing to annotate.  We skip it       -->
            <!-- promptly on the receiving end, instead of adding       -->
            <!-- clutter here.                                          -->
            <xsl:apply-templates select="." mode="view-source-knowl"/>
            <!-- Then actual content, respecting b-original flag  -->
            <!-- Pass $block-type for Sage cells to know environs -->
            <xsl:apply-templates select="." mode="wrapped-content">
                <xsl:with-param name="b-original" select="$b-original" />
                <xsl:with-param name="block-type" select="$block-type" />
            </xsl:apply-templates>
        </xsl:element>
        <!-- postlude afterward, when original -->
        <xsl:if test="$b-original">
            <xsl:apply-templates select="postlude">
                <xsl:with-param name="b-original" select="$b-original" />
            </xsl:apply-templates>
        </xsl:if>
    </xsl:template>

    <!-- TEMPORARY: var/li is a WeBWorK popup or radio button, -->
    <!-- which is not a cross-reference target (it originates  -->
    <!-- in PG-code), and an error results when the heading in -->
    <!-- the knowl content tries to compute a number           -->
    <xsl:template match="slide" mode="xref-as-knowl">
        <xsl:param name="link" select="/.." />
        <xsl:choose>
            <xsl:when test="$b-skip-knowls or $html-xref-knowled = 'never'">
                <xsl:value-of select="false()"/>
            </xsl:when>
            <xsl:when test="$html-xref-knowled = 'maximum'">
                <xsl:value-of select="true()"/>
            </xsl:when>
            <xsl:otherwise>
                <!-- Case $html-xref-knowled = 'cross-page'                                    -->
                <!-- Find the nearest common ancestor of the link and target                   -->
                <xsl:variable name="nearest-common-ancestor"
                            select="./ancestor::*[count(. | $link/ancestor::*) = count($link/ancestor::*)] [1]"/>
                <xsl:variable name="nearest-ancestor-level">
                    <xsl:apply-templates select="$nearest-common-ancestor" mode="enclosing-level"/>
                </xsl:variable>
                <!-- remove not(), replace operator with <, then radically different behavior -->
                <xsl:value-of select="not($nearest-ancestor-level >= $chunk-level)"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
   
    <!-- Paragraphs -->
    <!-- Technically a division, but small enough to xref knowl -->

    <!-- Never born-hidden, does not make sense -->
    <xsl:template match="slide" mode="is-hidden">
        <xsl:text>false</xsl:text>
    </xsl:template>

    <!-- Overall enclosing element -->
    <xsl:template match="slide" mode="body-element">
        <xsl:text>section</xsl:text>
    </xsl:template>

    <!-- And its CSS class -->
    <xsl:template match="slide" mode="body-css-class">
        <xsl:value-of select="local-name()"/>
    </xsl:template>

    <!-- When born use this heading -->
    <xsl:template match="slide" mode="heading-birth">
        <xsl:apply-templates select="." mode="heading-title-paragraphs" />
    </xsl:template>

    <!-- Heading for interior of xref-knowl content -->
    <xsl:template match="slide" mode="heading-xref-knowl">
        <xsl:apply-templates select="." mode="heading-title-paragraphs" />
    </xsl:template>

    <!-- Primary content of generic "body" template   -->
    <!-- Pass along b-original flag                   -->
    <!-- Simply process contents, could restrict here -->
    <xsl:template match="slide" mode="wrapped-content">
        <xsl:param name="b-original" select="true()" />
        <xsl:apply-templates>
            <xsl:with-param name="b-original" select="$b-original" />
        </xsl:apply-templates>
    </xsl:template>


</xsl:stylesheet>

Rob Beezer

unread,
Jul 11, 2024, 10:08:39 AMJul 11
to pretext...@googlegroups.com
Dear Stephen,

As you have discovered, hacking the XSL is unlikely to be very successful. But
you get points for trying. ;-)

And no, you can't expect a #slide in a #book to behave.

I thought using version support, along with including content (repeatedly) from
files might be an approach that would work. However each file must have a
single overall root element (#section? or #slide?), which seems to present the
same problem.

There has been interest in forming a #slideshow from a #book. In other words, a
stylesheet could convert a book into a #slideshow that could undergo subsequent
processing. Perhaps some markup (attributes) could guide this process.
Divisions become #slide, selected content is incorporated. We have @component
as part of version support, perhaps that could be recycled as a marker?

Rob


On 7/10/24 13:20, Stephen Flood wrote:
> Thanks for your help with this.  Adding the xml:id didn't change the issue, I
> think you're probably right that slides are not numbered.
>
> I know that <slide> as an element of <book> is not officially supported, and I
> don't think it makes sense to keep the slides all together in a book for the
> long term.  I'll just go crazy if I need to keep going between a dozen different
> PreTeXt documents as I try to put them together, and a nice feature of PreTeXt
> is it lets the reader easily switch between focusing on the big and small picture.
>
> My hope was to create an xsl file to extend the pretext-html.xsl that would help
> with this use case.
>
> Playing around with pretext-html.xsl, I have found that the following file
> causes the numbering errors to go away, but it no longer formats the titles of
> the slides as bold.  I found both blocks of code by searching pretext-html.xsl
> for "paragraphs", since they are un-numbered.
>
> I've tried copying all the rows where the match includes "paragraphs" and
> changing it to match="slides".  Is there more going on behind the scenes than I
> realize?
> <?xmlversion="1.0"encoding="UTF-8"?>
> <xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0">
>     <xsl:importhref="./core/pretext-html.xsl"/>
>
>     <xsl:templatematch="slide">
>         <xsl:paramname="b-original"select="true()"/>
>         <xsl:variablename="hidden">
>             <xsl:apply-templatesselect="."mode="is-hidden"/>
>         </xsl:variable>
>         <xsl:choose>
> <!-- born-hidden case -->
>             <xsl:whentest="$hidden = 'true'">
>                 <xsl:apply-templatesselect="."mode="born-hidden">
>                     <xsl:with-paramname="b-original"select="$b-original"/>
>                 </xsl:apply-templates>
>             </xsl:when>
> <!-- born-visible case -->
>             <xsl:otherwise>
> <!-- pass-thru of b-original mandatory -->
>                 <xsl:apply-templatesselect="."mode="born-visible">
>                     <xsl:with-paramname="b-original"select="$b-original"/>
>                 </xsl:apply-templates>
>             </xsl:otherwise>
>         </xsl:choose>
>     </xsl:template>
>
> <!-- All of the implementations above use the same   -->
> <!-- template for their body, it relies on various   -->
> <!-- templates but most of the work comes via the    -->
> <!-- "wrapped-content" template.  Here is that       -->
> <!-- "body" template.  The items in the "match"      -->
> <!-- are in the order presented above: simple first, -->
> <!-- and top-down when components are also knowled.  -->
>
>
>     <xsl:templatematch="paragraphs"mode="body">
>         <xsl:paramname="b-original"select="true()"/>
>         <xsl:paramname="block-type"/>
>
> <!-- prelude beforehand, when original -->
>         <xsl:iftest="$b-original">
>             <xsl:apply-templatesselect="prelude">
>                 <xsl:with-paramname="b-original"select="$b-original"/>
>             </xsl:apply-templates>
>         </xsl:if>
>         <xsl:variablename="body-elt">
>             <xsl:apply-templatesselect="."mode="body-element"/>
>         </xsl:variable>
>         <xsl:elementname="{$body-elt}">
>             <xsl:attributename="class">
>                 <xsl:apply-templatesselect="."mode="body-css-class"/>
>                 <xsl:iftest="$block-type = 'hidden'">
>                     <xsl:text> knowl__content</xsl:text>
>                 </xsl:if>
>             </xsl:attribute>
> <!-- Label original, but not if embedded            -->
> <!-- Then id goes onto the knowl text, so locatable -->
>             <xsl:iftest="$b-original and not($block-type = 'hidden')">
>                 <xsl:apply-templatesselect="."mode="html-id-attribute"/>
>                 <xsl:apply-templatesselect="."mode="permid-attribute"/>
>             </xsl:if>
> <!-- If visible, heading interior to article -->
>             <xsl:iftest="$block-type = 'visible'">
>                 <xsl:apply-templatesselect="."mode="heading-birth"/>
>             </xsl:if>
> <!-- If xref-knowl, heading interior to article -->
>             <xsl:iftest="$block-type = 'xref'">
>                 <xsl:apply-templatesselect="."mode="heading-xref-knowl"/>
>             </xsl:if>
> <!-- After the heading, and before the actual guts, we      -->
> <!-- sometimes annotate with a knowl showing the source     -->
> <!-- of the current element.  This calls a stub, unless     -->
> <!-- a separate stylesheet is used to define the template,  -->
> <!-- and the method is defined there.  An "fn" necessarily  -->
> <!-- comes through here since it is realized as a knowl,    -->
> <!-- but it is a silly thing to annotate.  We skip it       -->
> <!-- promptly on the receiving end, instead of adding       -->
> <!-- clutter here.                                          -->
>             <xsl:apply-templatesselect="."mode="view-source-knowl"/>
> <!-- Then actual content, respecting b-original flag  -->
> <!-- Pass $block-type for Sage cells to know environs -->
>             <xsl:apply-templatesselect="."mode="wrapped-content">
>                 <xsl:with-paramname="b-original"select="$b-original"/>
>                 <xsl:with-paramname="block-type"select="$block-type"/>
>             </xsl:apply-templates>
>         </xsl:element>
> <!-- postlude afterward, when original -->
>         <xsl:iftest="$b-original">
>             <xsl:apply-templatesselect="postlude">
>                 <xsl:with-paramname="b-original"select="$b-original"/>
>             </xsl:apply-templates>
>         </xsl:if>
>     </xsl:template>
>
> <!-- TEMPORARY: var/li is a WeBWorK popup or radio button, -->
> <!-- which is not a cross-reference target (it originates  -->
> <!-- in PG-code), and an error results when the heading in -->
> <!-- the knowl content tries to compute a number           -->
>     <xsl:templatematch="slide"mode="xref-as-knowl">
>         <xsl:paramname="link"select="/.."/>
>         <xsl:choose>
>             <xsl:whentest="$b-skip-knowls or $html-xref-knowled = 'never'">
>                 <xsl:value-ofselect="false()"/>
>             </xsl:when>
>             <xsl:whentest="$html-xref-knowled = 'maximum'">
>                 <xsl:value-ofselect="true()"/>
>             </xsl:when>
>             <xsl:otherwise>
> <!-- Case $html-xref-knowled = 'cross-page'                                    -->
> <!-- Find the nearest common ancestor of the link and target                   -->
> <!-- https://stackoverflow.com/questions/538293/find-common-parent-using-xpath -->
>                 <xsl:variablename="nearest-common-ancestor"
> select="./ancestor::*[count(. | $link/ancestor::*) = count($link/ancestor::*)]
> [1]"/>
>                 <xsl:variablename="nearest-ancestor-level">
>
> <xsl:apply-templatesselect="$nearest-common-ancestor"mode="enclosing-level"/>
>                 </xsl:variable>
> <!-- remove not(), replace operator with <, then radically different behavior -->
>                 <xsl:value-ofselect="not($nearest-ancestor-level >=
> $chunk-level)"/>
>             </xsl:otherwise>
>         </xsl:choose>
>     </xsl:template>
> <!-- Paragraphs -->
> <!-- Technically a division, but small enough to xref knowl -->
>
> <!-- Never born-hidden, does not make sense -->
>     <xsl:templatematch="slide"mode="is-hidden">
>         <xsl:text>false</xsl:text>
>     </xsl:template>
>
> <!-- Overall enclosing element -->
>     <xsl:templatematch="slide"mode="body-element">
>         <xsl:text>section</xsl:text>
>     </xsl:template>
>
> <!-- And its CSS class -->
>     <xsl:templatematch="slide"mode="body-css-class">
>         <xsl:value-ofselect="local-name()"/>
>     </xsl:template>
>
> <!-- When born use this heading -->
>     <xsl:templatematch="slide"mode="heading-birth">
>         <xsl:apply-templatesselect="."mode="heading-title-paragraphs"/>
>     </xsl:template>
>
> <!-- Heading for interior of xref-knowl content -->
>     <xsl:templatematch="slide"mode="heading-xref-knowl">
>         <xsl:apply-templatesselect="."mode="heading-title-paragraphs"/>
>     </xsl:template>
>
> <!-- Primary content of generic "body" template   -->
> <!-- Pass along b-original flag                   -->
> <!-- Simply process contents, could restrict here -->
>     <xsl:templatematch="slide"mode="wrapped-content">
>         <xsl:paramname="b-original"select="true()"/>
>         <xsl:apply-templates>
>             <xsl:with-paramname="b-original"select="$b-original"/>
> https://groups.google.com/d/msgid/pretext-support/4a106a0d-2d7c-4ce1-87ad-de4df16f032bn%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/4a106a0d-2d7c-4ce1-87ad-de4df16f032bn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com
> <mailto:pretext-suppo...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-support/7e4908bb-1ea9-4a3c-9108-d7279e40a9dbn%40googlegroups.com <https://groups.google.com/d/msgid/pretext-support/7e4908bb-1ea9-4a3c-9108-d7279e40a9dbn%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages