Skip to content

Commit 3dfc8e3

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 3dfc8e3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

source/macros.tex

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,19 @@
235235
%%--------------------------------------------------
236236
\newcommand{\CodeStyle}{\ttfamily}
237237
\newcommand{\CodeStylex}[1]{\texttt{\protect\frenchspacing #1}}
238+
\makeatletter
239+
% Append `\@` to restore proper sentence spacing in text mode. This insertion
240+
% happens only during normal typesetting; it is suppressed for .idx generation.
241+
\newcommand{\CodeStylexGuarded}[1]{\CodeStylex{#1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}}
242+
\makeatother
238243

239244
\definecolor{grammar-gray}{gray}{0.2}
240245

241246
% General grammar style
242247
\newcommand{\GrammarStylex}[1]{\textcolor{grammar-gray}{\textsf{\textit{#1}}}}
243248

244249
% Code and definitions embedded in text.
245-
\newcommand{\tcode}[1]{\CodeStylex{#1}}
250+
\newcommand{\tcode}[1]{\CodeStylexGuarded{#1}}
246251
\newcommand{\term}[1]{\textit{#1}}
247252
\newcommand{\gterm}[1]{\GrammarStylex{#1}}
248253
\newcommand{\fakegrammarterm}[1]{\gterm{#1}}
@@ -592,7 +597,7 @@
592597
\lstset{escapechar=@, aboveskip=\parskip, belowskip=0pt,
593598
midpenalty=500, endpenalty=-50,
594599
emptylinepenalty=-250, semicolonpenalty=0,upquote=true}%
595-
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
600+
\renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}}
596601
\renewcommand{\term}[1]{\textit{##1}}%
597602
\renewcommand{\grammarterm}[1]{\gterm{##1}}%
598603
}
@@ -650,7 +655,7 @@
650655
belowskip=0ex % leave this alone: it keeps these things out of the
651656
% footnote area
652657
}%
653-
\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}}
658+
\renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}}
654659
}
655660
{
656661
}

0 commit comments

Comments
 (0)