diff --git a/source/macros.tex b/source/macros.tex index 39577ed108..ae5591106e 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -235,6 +235,11 @@ %%-------------------------------------------------- \newcommand{\CodeStyle}{\ttfamily} \newcommand{\CodeStylex}[1]{\texttt{\protect\frenchspacing #1}} +\makeatletter +% Append `\@` to restore proper sentence spacing in text mode. This insertion +% happens only during normal typesetting; it is suppressed for .idx generation. +\newcommand{\CodeStylexGuarded}[1]{\CodeStylex{#1\ifmmode\else\ifx\protect\@typeset@protect\@\fi\fi}} +\makeatother \definecolor{grammar-gray}{gray}{0.2} @@ -242,7 +247,7 @@ \newcommand{\GrammarStylex}[1]{\textcolor{grammar-gray}{\textsf{\textit{#1}}}} % Code and definitions embedded in text. -\newcommand{\tcode}[1]{\CodeStylex{#1}} +\newcommand{\tcode}[1]{\CodeStylexGuarded{#1}} \newcommand{\term}[1]{\textit{#1}} \newcommand{\gterm}[1]{\GrammarStylex{#1}} \newcommand{\fakegrammarterm}[1]{\gterm{#1}} @@ -592,7 +597,7 @@ \lstset{escapechar=@, aboveskip=\parskip, belowskip=0pt, midpenalty=500, endpenalty=-50, emptylinepenalty=-250, semicolonpenalty=0,upquote=true}% -\renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}} +\renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}} \renewcommand{\term}[1]{\textit{##1}}% \renewcommand{\grammarterm}[1]{\gterm{##1}}% } @@ -650,7 +655,7 @@ belowskip=0ex % leave this alone: it keeps these things out of the % footnote area }% - \renewcommand{\tcode}[1]{\textup{\CodeStylex{##1}}} + \renewcommand{\tcode}[1]{\textup{\CodeStylexGuarded{##1}}} } { }