PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
266 stars 208 forks source link

captions and sbsgroup #954

Closed dbrianwalton closed 6 years ago

dbrianwalton commented 6 years ago

The following basic structure for a figure when compiled to a LaTeX document resulted in a LaTeX error:

! Undefined control sequence. l.610 \subcaption {Domain: ((-\infty,\infty))\label{figure-3}}

It was pointed out in the pretext-support group that the subcaption package is not being included for the document in this case. Alex Jordan wrote:

I have seen this before. The XSLT text determining whether to load the subcaption package is not set up to detect the need when a sbsgroup is involved. It is: $document-root//figure/sidebyside/*[caption] which neglects the scenario where there is a sbsgroup between the figure and the sidebyside.

Here is my basic structure. The error arose when this was the only figure in my short test document.

    <figure>
      <caption/>
      <sbsgroup>
        <sidebyside widths="45% 45%">
          <figure>
            <caption>First caption </caption>
            <image>
              <latex-image />
            </image>
          </figure>
          <figure>
            <caption>Second caption</caption>
            <image>
              <latex-image />
            </image>
          </figure>
        </sidebyside>
        <sidebyside widths="45% 45%">
          <figure>
            <caption>Third caption </caption>
            <image>
              <latex-image />
            </image>
          </figure>
          <figure>
            <caption>Fourth caption</caption>
            <image>
              <latex-image />
            </image>
          </figure>
        </sidebyside>
      </sbsgroup>
    </figure>
Alex-Jordan commented 6 years ago

Note that if you dropped Brian's example into the sample article it would probably come out fine because other things in the sample article trigger the subcaption package to be added to the preamble. But if you drop it into the minimal example you will probably see the bad behavior.

dbrianwalton commented 6 years ago

In mathbook-latex.xsl, if I changed line 1131 from <xsl:if test="$document-root//figure/sidebyside/*[caption]"> to <xsl:if test="$document-root//figure/sidebyside/*[caption] | $document-root//figure/sbsgroup/sidebyside/*[caption]"> my issue goes away.

rbeezer commented 6 years ago

Excellent. Thanks, Alex and Brian, for the debugging. This sort of error is the one big drawback to developing with the sample article.

Brian - it'll take me just a few minutes to fix this, once I get some spare minutes. BUT, if you would like to make a pull request with this edit, I'd be happy to work with you to get it in that way. Your call - either way is fine with me.

On 09/07/2018 12:27 PM, dbrianwalton wrote:

In mathbook-latex.xsl, if I changed line 1131 from || to || my issue goes away.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rbeezer/mathbook/issues/954#issuecomment-419541805, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy2cgut2Sl-EK_9WoN2UP113QpQ8PCNks5uYsiwgaJpZM4WfTbv.

dbrianwalton commented 6 years ago

First attempt at a pull request, so hope I did it correctly.

rbeezer commented 6 years ago

Pull request accepted at #955. Thanks again, Brian and Alex.