Skip to content

[macros] Restore sentence spacing after \tcode #8160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

morinmorin
Copy link
Contributor

TeX treats a word ending with an uppercase letter as an abbreviation. This makes the space after \tcode{T}. result in regular interword spacing. To restore proper (wider) sentence spacing, this commit appends \@ to the \tcode macro.

There are dozens of intances of \tcode{...UPPERCASE}.

@jensmaurer
Copy link
Member

Could you paste a (small) screenshot of an example showing the spacing before/after this change?

Did you run "diffpdf" in a sufficiently detailed mode to ensure nothing gets broken?

@@ -242,7 +242,7 @@
\newcommand{\GrammarStylex}[1]{\textcolor{grammar-gray}{\textsf{\textit{#1}}}}

% Code and definitions embedded in text.
\newcommand{\tcode}[1]{\CodeStylex{#1}}
\newcommand{\tcode}[1]{\ifmmode\CodeStylex{#1}\else\CodeStylex{#1}\@\fi}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment like "restore normal sentence spacing when not in math mode"?

@tkoeppe
Copy link
Contributor

tkoeppe commented Aug 15, 2025

This change seems to cause us to lose some index entries. Please see std-generalindex.ilg.

@morinmorin morinmorin changed the title [macros] Fix sentence spacing after \tcode [WIP] [macros] Fix sentence spacing after \tcode Aug 15, 2025
@morinmorin
Copy link
Contributor Author

Sorry for the breakage. I'll dig into it more and I'll attach a diff screenshot after it's resolved.

@morinmorin morinmorin force-pushed the fix_spacing_after_tcode branch from 01dcd2e to 4aee7f1 Compare August 17, 2025 01:57
@morinmorin morinmorin changed the title [WIP] [macros] Fix sentence spacing after \tcode [macros] Restore sentence spacing after \tcode Aug 17, 2025
@morinmorin
Copy link
Contributor Author

OK, fixed the breakage and added a comment.

@morinmorin
Copy link
Contributor Author

There are hundreds of spacing updates.
Many are subtle/unnoticeable (typical patterns: \tcode{…UPPERCASE}, and \tcode{…UPPERCASE}; ):
diff1

Here is a typical sentence-spacing fix involving \tcode{…UPPERCASE}. :
diff2

In a few places, multiple lines reflow slightly:
diff3

There is only one instance where a paragraph extends by one line, causing a substantial page reflow (from [linalg.general] p4 to [linalg.algs.blas3.trmm] p8). This change only shifts a page break — confirmed with pdfdiff — so I think this is fine.
diff4

How to read these images (generated by diff-pdf):
Differences are color-coded — red indicates the original and cyan indicates the revised. Any line that contains a difference is marked with a red marker in the left margin.

@morinmorin
Copy link
Contributor Author

Oops, forgot to reply to this one.

Did you run "diffpdf" in a sufficiently detailed mode to ensure nothing gets broken?

After fixing the breakage, yes, I checked with DiffPDF (and diff-pdf) and didn't find any particular problems.

\makeatletter
% Append `\@` to restore proper sentence spacing in text mode. This insertion
% happens only during normal typesetting; it is suppressed for .idx generation.
\newcommand{\tcode}[1]{\CodeStylex{#1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we factor the common logic out into some helper macro (to be put say on L238) which can be used both here and in the two redefinitions below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, fixed!

TeX treats a word ending with an uppercase letter as an abbreviation.
This makes the space after `\tcode{T}.` result in regular interword
spacing. To restore proper (wider) sentence spacing, this commit
appends `\@` to the `\tcode` command. The insertion of `\@` happens
only during normal typesetting; it is suppressed when writing the .idx
file and when generating bookmarks.
@morinmorin morinmorin force-pushed the fix_spacing_after_tcode branch from 4aee7f1 to 3dfc8e3 Compare August 18, 2025 12:35
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.

3 participants