Journal texstyles number theorems within sections whatever `numbering/blocks/@level` says, so the PDF disagrees with the HTML made from the same publication file

オープン
#3,271 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
latex
領域
build-system

調査の方向性

Start in xsl/latex/pretext-latex-texstyle.xsl, at the theoremstyle template (around line 274), where the counter-defining \newtheorem is written with a literal [section] (around line 287). Compare it with how pretext-latex-classic.xsl (around line 773) uses $numbering-blocks and level-to-name. Build the minimal main.ptx and publication.ptx from the issue with -f pdf and -f html, then check that main.tex no longer has [section] when blocks/@level="0". Done when the PDF and HTML number theorem and definition blocks the same way for levels 0 and 1.

索引モデルが issue の本文から書いたものです。

説明

What happens

With a journal style in the publication file (<common><journal name="ams"/></common>), the LaTeX conversion writes \newtheorem{theorem}{Theorem}[section] unconditionally. The publication file's <numbering><blocks level="0"/></numbering> is not consulted. Theorem-like blocks are then numbered 1.1, 1.2, 2.1 in the PDF while the HTML (and EPUB) built from the same publication file number them 1, 2, 3, and every cross-reference differs between the two outputs.

Minimal source

main.ptx:

<?xml version="1.0" encoding="UTF-8"?>
<pretext xml:lang="en-US">
    <article xml:id="numbering-test">
        <title>Numbering of blocks in a journal style</title>
        <section xml:id="section-one">
            <title>First section</title>
            <theorem xml:id="theorem-first"><statement><p>First.</p></statement></theorem>
            <definition xml:id="definition-second"><statement><p>Second.</p></statement></definition>
        </section>
        <section xml:id="section-two">
            <title>Second section</title>
            <theorem xml:id="theorem-third"><statement><p>Third, by <xref ref="theorem-first"/>.</p></statement></theorem>
        </section>
    </article>
</pretext>

publication.ptx:

<?xml version="1.0" encoding="UTF-8"?>
<publication>
    <common><journal name="ams"/></common>
    <numbering><blocks level="0"/></numbering>
</publication>

Commands:

pretext/pretext -c doc -f pdf  -p publication.ptx -d out-pdf  main.ptx
pretext/pretext -c doc -f html -p publication.ptx -d out-html main.ptx

Observed

The PDF: "Theorem 1.1.", "Definition 1.2.", "Theorem 2.1. Third, by Theorem 1.1." The generated main.tex has

\newtheorem{theorem}{Theorem}[section]
\newtheorem{definition}[theorem]{Definition}

The HTML from the same publication file: "Theorem 1", "Definition 2", "Theorem 3", and the reference reads "Theorem 1".

Expected

The same numbers in both: with blocks/@level="0", Theorem 1, Definition 2, Theorem 3 in the PDF too (\newtheorem{theorem}{Theorem} with no [section]); with @level="1", [section]; and so on, as the ordinary LaTeX conversion does.

Cause (xsl/latex/pretext-latex-texstyle.xsl at bf795ab1)

The template match="theoremstyle" (line 274) writes the counter-defining \newtheorem for the first theoremstyle of the texstyle file, and the optional argument is a literal:

<xsl:if test="not(preceding-sibling::theoremstyle) and not(@define-counter='no')">
    <xsl:text>\newtheorem{theorem}{</xsl:text>
    <xsl:apply-templates select="($document-root//theorem)[1]" mode="type-name"/>
    <xsl:text>}[section]&#xa;</xsl:text>
</xsl:if>

(line 284 to 288; the [section] is on line 287). This stylesheet imports ../pretext-latex-classic.xsl (line 40), which already derives the level for its own block counter from the publication file, at line 773:

<xsl:if test="not($numbering-blocks = 0)">
    <xsl:text>, number within=</xsl:text>
    <xsl:call-template name="level-to-name">
        <xsl:with-param name="level" select="$numbering-blocks" />
    </xsl:call-template>
</xsl:if>

so $numbering-blocks and level-to-name (in pretext-common.xsl, line 581) are both available where the \newtheorem is written. Every journal texstyle is affected, since all go through this template; journals/texstyles/ams.xml line 36 is the theoremstyle that triggers it for the AMS style.

Suggested fix

Replace line 287 by the same construction the classic conversion uses:

    <xsl:text>}</xsl:text>
    <xsl:if test="not($numbering-blocks = 0)">
        <xsl:text>[</xsl:text>
        <xsl:call-template name="level-to-name">
            <xsl:with-param name="level" select="$numbering-blocks"/>
        </xsl:call-template>
        <xsl:text>]</xsl:text>
    </xsl:if>
    <xsl:text>&#xa;</xsl:text>

level-to-name returns section, subsection, and so on for an article, which is what amsthm's optional argument takes. If a particular journal's class fixes its own numbering, that is what @define-counter="no" on the theoremstyle is for, and this change does not touch that path.

@oscarlevin, for the texstyle side.

Environment: commit bf795ab1 (2026-10-02), xelatex (TeX Live 2024), Debian 13.

主要言語
XSLT
スター
466
フォーク
251
平均マージ
4分
マージ済み PR(30日)
13

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PreTeXtBook/pretext のほかの issue

PreTeXtBook/pretext の issue をすべて見る

似ている issue

Build System の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。