Skip to content

Commit 4aee7f1

Browse files
committed
[macros] Restore sentence spacing after \tcode
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.
1 parent a449305 commit 4aee7f1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

source/macros.tex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,11 @@
242242
\newcommand{\GrammarStylex}[1]{\textcolor{grammar-gray}{\textsf{\textit{#1}}}}
243243

244244
% Code and definitions embedded in text.
245-
\newcommand{\tcode}[1]{\CodeStylex{#1}}
245+
\makeatletter
246+
% Append `\@` to restore proper sentence spacing in text mode. This insertion
247+
% happens only during normal typesetting; it is suppressed for .idx generation.
248+
\newcommand{\tcode}[1]{\CodeStylex{#1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}}
249+
\makeatother
246250
\newcommand{\term}[1]{\textit{#1}}
247251
\newcommand{\gterm}[1]{\GrammarStylex{#1}}
248252
\newcommand{\fakegrammarterm}[1]{\gterm{#1}}
@@ -592,7 +596,9 @@
592596
\lstset{escapechar=@, aboveskip=\parskip, belowskip=0pt,
593597
midpenalty=500, endpenalty=-50,
594598
emptylinepenalty=-250, semicolonpenalty=0,upquote=true}%
595-
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
599+
\makeatletter
600+
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}}}
601+
\makeatother
596602
\renewcommand{\term}[1]{\textit{##1}}%
597603
\renewcommand{\grammarterm}[1]{\gterm{##1}}%
598604
}
@@ -650,7 +656,9 @@
650656
belowskip=0ex % leave this alone: it keeps these things out of the
651657
% footnote area
652658
}%
653-
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
659+
\makeatletter
660+
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}}}
661+
\makeatother
654662
}
655663
{
656664
}

0 commit comments

Comments
 (0)