Journal texstyles number theorems within sections whatever `numbering/blocks/@level` says, so the PDF disagrees with the HTML made from the same publication file
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- Medio día
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- latex
- Área
- build-system
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- XSLT
- Estrellas
- 466
- Forks
- 251
- Merge medio
- 4 min
- PR fusionados (30 d)
- 13
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PreTeXtBook/pretext
-
The print preview leaves writing space short by the margins of hidden headers, footers and solutionsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PreTeXtBook/pretext#3329 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
PreTeXtBook/pretext#3305 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PreTeXtBook/pretext#3297 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
PreTeXtBook/pretext#3285 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PreTeXtBook/pretext#3283 ·
Los mantenedores suelen responder en 1 día
Todos los issues de PreTeXtBook/pretext
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
NativeScript/ios#577 ·
Los mantenedores suelen responder en 1 día
-
bot:ai-assisted component:platform-js status:untriaged
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
midnightntwrk/platform-js#38 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
oxc-project/tsrs#1010 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
rubys/roundhouse#2217 ·