Journal texstyles number theorems within sections whatever `numbering/blocks/@level` says, so the PDF disagrees with the HTML made from the same publication file
メンテナーはふだん 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]
</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>
</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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PreTeXtBook/pretext のほかの issue
-
The print preview leaves writing space short by the margins of hidden headers, footers and solutionsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PreTeXtBook/pretext#3329 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
PreTeXtBook/pretext#3305 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PreTeXtBook/pretext#3297 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
PreTeXtBook/pretext#3285 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
PreTeXtBook/pretext#3283 ·
メンテナーはふだん 1 日以内に返信
PreTeXtBook/pretext の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
NativeScript/ios#577 ·
メンテナーはふだん 1 日以内に返信
-
bot:ai-assisted component:platform-js status:untriaged
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
midnightntwrk/platform-js#38 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
oxc-project/tsrs#1010 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
rubys/roundhouse#2217 ·