Skip to content

Commit 3acd7a0

Browse files
jensmaurertkoeppe
authored andcommitted
[macros] Allow \keyword and \grammarterm in section headings
by disabling all indexing when typesetting the table-of-contents.
1 parent 0c53bea commit 3acd7a0

File tree

4 files changed

+25
-17
lines changed

4 files changed

+25
-17
lines changed

source/declarations.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@
559559
\end{codeblock}
560560
\end{example}
561561

562-
\rSec2[dcl.typedef]{The \tcode{typedef} specifier}%
562+
\rSec2[dcl.typedef]{The \keyword{typedef} specifier}%
563563
\indextext{specifier!\idxcode{typedef}}
564564

565565
\pnum
@@ -698,14 +698,14 @@
698698
\end{codeblock}
699699
\end{example}
700700

701-
\rSec2[dcl.friend]{The \tcode{friend} specifier}%
701+
\rSec2[dcl.friend]{The \keyword{friend} specifier}%
702702
\indextext{specifier!\idxcode{friend}}
703703

704704
\pnum
705705
The \keyword{friend} specifier is used to specify access to class members;
706706
see~\ref{class.friend}.
707707

708-
\rSec2[dcl.constexpr]{The \tcode{constexpr} and \tcode{consteval} specifiers}%
708+
\rSec2[dcl.constexpr]{The \keyword{constexpr} and \keyword{consteval} specifiers}%
709709
\indextext{specifier!\idxcode{constexpr}}
710710
\indextext{specifier!\idxcode{consteval}}
711711

@@ -953,7 +953,7 @@
953953
\end{codeblock}
954954
\end{example}
955955

956-
\rSec2[dcl.constinit]{The \tcode{constinit} specifier}
956+
\rSec2[dcl.constinit]{The \keyword{constinit} specifier}
957957
\indextext{specifier!\idxcode{constinit}}
958958

959959
\pnum
@@ -982,7 +982,7 @@
982982
\end{codeblock}
983983
\end{example}
984984

985-
\rSec2[dcl.inline]{The \tcode{inline} specifier}%
985+
\rSec2[dcl.inline]{The \keyword{inline} specifier}%
986986
\indextext{specifier!\idxcode{inline}}
987987

988988
\pnum

source/front.tex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,19 @@
1212
\renewcommand\@pnumwidth{2.5em}
1313
\makeatother
1414

15+
% Disable indexing within the table of contents
16+
\newcommand{\indexoff}[2][generalindex]{}
17+
\let\oindex\index
18+
\let\index\indexoff
19+
1520
%% Include table of contents. Do not list "Contents"
1621
%% within it (per ISO request) but do include a
1722
%% bookmark for it in the PDF.
1823
\phantomsection
1924
\pdfbookmark{\contentsname}{toctarget}
2025
\hypertarget{toctarget}{\tableofcontents*}
2126

27+
% Restore indexing
28+
\let\index\oindex
29+
2230
\setcounter{tocdepth}{5}

source/macros.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@
226226
\newcommand{\term}[1]{\textit{#1}}
227227
\newcommand{\gterm}[1]{\GrammarStylex{#1}}
228228
\newcommand{\fakegrammarterm}[1]{\gterm{#1}}
229-
\newcommand{\keyword}[1]{\tcode{#1}\indextext{\idxcode{#1}!keyword}} % macro length: 8
230-
\newcommand{\grammarterm}[1]{\indexgram{\idxgram{#1}}\gterm{#1}}
229+
\newcommand{\keyword}[1]{\texorpdfstring{\tcode{#1}\protect\indextext{\idxcode{#1}!keyword}}{#1}} % macro length: 8
230+
\newcommand{\grammarterm}[1]{\texorpdfstring{\protect\indexgram{\idxgram{#1}}\gterm{#1}}{#1}}
231231
\newcommand{\grammartermnc}[1]{\indexgram{\idxgram{#1}}\gterm{#1\nocorr}}
232232
\newcommand{\regrammarterm}[1]{\textit{#1}}
233233
\newcommand{\placeholder}[1]{\textit{#1}} % macro length: 12

source/statements.tex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
has a block scope\iref{basic.scope.block}.
232232
\end{note}
233233

234-
\rSec2[stmt.if]{The \tcode{if} statement}%
234+
\rSec2[stmt.if]{The \keyword{if} statement}%
235235
\indextext{statement!\idxcode{if}}
236236

237237
\pnum
@@ -376,7 +376,7 @@
376376
\keyword{if} \keyword{consteval} statement$_2$ \keyword{else} compound-statement$_1$
377377
\end{ncsimplebnf}
378378

379-
\rSec2[stmt.switch]{The \tcode{switch} statement}%
379+
\rSec2[stmt.switch]{The \keyword{switch} statement}%
380380
\indextext{statement!\idxcode{switch}}
381381

382382
\pnum
@@ -518,7 +518,7 @@
518518
Thus after the \keyword{while} statement, \tcode{i} is no longer in scope.
519519
\end{example}
520520

521-
\rSec2[stmt.while]{The \tcode{while} statement}%
521+
\rSec2[stmt.while]{The \keyword{while} statement}%
522522
\indextext{statement!\idxcode{while}}
523523

524524
\pnum
@@ -562,7 +562,7 @@
562562
\end{example}
563563
\end{note}
564564

565-
\rSec2[stmt.do]{The \tcode{do} statement}%
565+
\rSec2[stmt.do]{The \keyword{do} statement}%
566566
\indextext{statement!\idxcode{do}}
567567

568568
\pnum
@@ -614,7 +614,7 @@
614614
makes the implied \keyword{while} clause
615615
equivalent to \tcode{while(true)}.
616616

617-
\rSec2[stmt.ranged]{The range-based \tcode{for} statement}%
617+
\rSec2[stmt.ranged]{The range-based \keyword{for} statement}%
618618
\indextext{statement!range based for@range based \tcode{for}}
619619

620620
\pnum
@@ -736,7 +736,7 @@
736736
A suspension of a coroutine\iref{expr.await} is not considered to be an exit from a scope.
737737
\end{note}
738738

739-
\rSec2[stmt.break]{The \tcode{break} statement}%
739+
\rSec2[stmt.break]{The \keyword{break} statement}%
740740
\indextext{statement!\idxcode{break}}
741741

742742
\pnum
@@ -748,7 +748,7 @@
748748
\keyword{switch} statement; control passes to the statement following the
749749
terminated statement, if any.
750750

751-
\rSec2[stmt.cont]{The \tcode{continue} statement}%
751+
\rSec2[stmt.cont]{The \keyword{continue} statement}%
752752
\indextext{statement!\idxcode{continue}}
753753

754754
\pnum
@@ -795,7 +795,7 @@
795795
a \keyword{continue} not contained in an enclosed iteration statement is
796796
equivalent to \tcode{goto} \exposid{contin}.
797797

798-
\rSec2[stmt.return]{The \tcode{return} statement}%
798+
\rSec2[stmt.return]{The \keyword{return} statement}%
799799
\indextext{\idxcode{return}}%
800800
\indextext{function return|see{\tcode{return}}}%
801801

@@ -859,7 +859,7 @@
859859
before the destruction of local variables\iref{stmt.jump} of the block
860860
enclosing the \tcode{return} statement.
861861

862-
\rSec2[stmt.return.coroutine]{The \tcode{co_return} statement}%
862+
\rSec2[stmt.return.coroutine]{The \keyword{co_return} statement}%
863863
\indextext{\idxcode{co_return}}%
864864
\indextext{coroutine return|see{\tcode{co_return}}}%
865865

@@ -910,7 +910,7 @@
910910
otherwise flowing off the end of a coroutine's \grammarterm{function-body}
911911
results in undefined behavior.
912912

913-
\rSec2[stmt.goto]{The \tcode{goto} statement}%
913+
\rSec2[stmt.goto]{The \keyword{goto} statement}%
914914
\indextext{statement!\idxcode{goto}}
915915

916916
\pnum

0 commit comments

Comments
 (0)