Skip to content

Fix \title, \author and \date with an optional short argument - #142

Closed
Sanjays2402 wants to merge 1 commit into
phfaist:mainfrom
Sanjays2402:fix/title-author-date-optional-arg
Closed

Sanjays2402 wants to merge 1 commit into
phfaist:mainfrom
Sanjays2402:fix/title-author-date-optional-arg

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #114.

\title[short]{full} (and likewise \author / \date) did not declare the optional argument in the latexwalker spec, so the [short] part stayed as plain character nodes and the mandatory argument was never picked up — latex_to_text() returned the raw short]full text and \maketitle rendered a stray [. Declaring the optional argument ('[{') and reading the mandatory one at index 1 in the latex2text specs fixes both the bracketed and plain forms.

Regression test added in test_2_latex2text.py; it fails on master and passes with the fix, and the full suite (342 tests) is green.

\title[short]{full} (and the same for \author and \date) was parsed with
the optional argument missing from the macro spec, so the leading "[" and
the short text were left as ordinary character nodes and the mandatory
argument was never recognised. latex_to_text() then emitted the raw
"short]full" text, and \maketitle rendered a stray "[".

Declare the optional argument in the latexwalker specs ('[{' instead of
'{') and read the mandatory argument at index 1 in the latex2text specs.

Adds a regression test covering \title/\author/\date with a short argument.
@phfaist

phfaist commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Rebased, added important comments and fixes, and merged into main. Closing.

@phfaist phfaist closed this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to extract Title in common cases in both pylatexenc V2 and V3

2 participants