Journal texstyles: no space after the title of a `case`, and a bare `case` loses its period

Open Beginner friendly
#3,272 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
latex
Domain
build-system

Research direction

The bug is in the match="case" template of xsl/pretext-latex-classic.xsl (around line 573), where the title and type-name branches write \textit{...} with no following space and no period. Compare with the case environment heading in xsl/pretext-latex-common.xsl (mode="environment", around line 2577). Build the minimal source with the journal publication file and inspect the generated main.tex. Done when the title and type-name branches emit a space (and a period after the type name), and the PDF reads "First case. Text..." and "Case. Text...".

Written by the indexing model from the issue text.

Description

What happens

In the LaTeX conversion for a journal style (the pretext-latex-classic.xsl conversion that every texstyle imports), a case of a proof with a title prints the title in italics and then the first paragraph immediately, with no space: "First case.Text of the first case." A case with neither title nor direction prints its type name the same way, and without the period: "CaseText of a case with no title." A case with a direction is right, because that branch alone writes a space.

Minimal source

main.ptx:

<?xml version="1.0" encoding="UTF-8"?>
<pretext xml:lang="en-US">
    <article xml:id="case-test">
        <title>A case title in a journal style</title>
        <section xml:id="section-one">
            <title>A section</title>
            <theorem xml:id="theorem-cases">
                <statement><p>Something holds.</p></statement>
                <proof>
                    <case><title>First case</title><p>Text of the first case.</p></case>
                    <case direction="forward"><p>Text of the forward direction.</p></case>
                    <case><p>Text of a case with no title.</p></case>
                </proof>
            </theorem>
        </section>
    </article>
</pretext>

publication.ptx:

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

Command:

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

Observed

In out/main.pdf:

First case.Text of the first case.
(⇒) Text of the forward direction.
CaseText of a case with no title.

The generated main.tex has, for the first case,

\noindent{}\textit{First case.}\label{theorem-cases-2-1}%
Text of the first case.%

Expected

What the same source gives without the journal entry in the publication file, and in HTML:

First case. Text of the first case.
(⇒) Text of the forward direction.
Case. Text of a case with no title.

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

The template match="case" (line 573):

<xsl:template match="case">
    <xsl:text>\par\medskip%&#xa;</xsl:text>
    <xsl:text>\noindent{}</xsl:text>
    <xsl:if test="@direction">
        <xsl:apply-templates select="." mode="case-direction"/>
        <xsl:text> </xsl:text>
    </xsl:if>
    <xsl:if test="title">
        <xsl:text>\textit{</xsl:text>
        <xsl:apply-templates select="." mode="title-full" />
        <xsl:text>}</xsl:text>
    </xsl:if>
    <xsl:if test="not(title) and not(@direction)">
        <xsl:text>\textit{</xsl:text>
        <xsl:apply-templates select="." mode="type-name"/>
        <xsl:text>}</xsl:text>
    </xsl:if>
    <!-- label -->
    <xsl:text>\label{</xsl:text>
    <xsl:apply-templates select="." mode="unique-id" />
    <xsl:text>}%&#xa;</xsl:text>
    <xsl:apply-templates select="*"/>
</xsl:template>

The direction branch ends with a space; the title branch and the type-name branch end with } and go straight to \label{...}% and the paragraph. title-full supplies the title's period, but nothing supplies one after the type name. For comparison, the ordinary LaTeX conversion defines a case environment (pretext-latex-common.xsl, mode="environment", line 2577) whose heading is

\notblank{#2}{#2\space{}}{}\textit{\notblank{#3}{#3\space{}}{}\notblank{#2#3}{}{#1.\space{}}}

a space after the direction, after the title, and after the type name, and a period after the type name.

Suggested fix

In the two branches, write the space (and the period for the type name) as the common conversion does:

    <xsl:if test="title">
        <xsl:text>\textit{</xsl:text>
        <xsl:apply-templates select="." mode="title-full" />
        <xsl:text>} </xsl:text>
    </xsl:if>
    <xsl:if test="not(title) and not(@direction)">
        <xsl:text>\textit{</xsl:text>
        <xsl:apply-templates select="." mode="type-name"/>
        <xsl:text>.} </xsl:text>
    </xsl:if>

The \label{...}% that follows ends its line with %, so the space before it survives into the paragraph; if it is thought safer, \space{} instead of a literal space.

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

Dominant language
XSLT
Stars
466
Forks
251
Avg merge
4m
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PreTeXtBook/pretext

All issues in PreTeXtBook/pretext

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.