|
1 | 1 | %!TEX root = std.tex |
| 2 | + |
2 | 3 | % Definitions and redefinitions of special commands |
| 4 | +% |
| 5 | +% For macros that are likely to appear inside code blocks, we may provide a |
| 6 | +% "macro length" correction value, which can be used to determine the effective |
| 7 | +% column number where an emitted character appears, by adding the macro length, |
| 8 | +% plus 2 for the escape-'@'s, plus 2 for the braces, to the real column number. |
| 9 | +% |
| 10 | +% For example: |
| 11 | +% |
| 12 | +% \newcommand{\foo[1]{#1} % macro length: 4 |
| 13 | +% |
| 14 | +% \begin{codeblock} |
| 15 | +% int a = 10; // comment on column 20 |
| 16 | +% int b = @\foo{x}@; // comment also on effective column 20 |
| 17 | +% |
| 18 | +% Here the real column of the second comment start is offset by 8 (4 + macro length). |
3 | 19 |
|
4 | 20 | %%-------------------------------------------------- |
5 | 21 | %% Difference markups |
| 22 | +%%-------------------------------------------------- |
6 | 23 | \definecolor{addclr}{rgb}{0,.6,.6} |
7 | 24 | \definecolor{remclr}{rgb}{1,0,0} |
8 | 25 | \definecolor{noteclr}{rgb}{0,0,1} |
|
18 | 35 | \newcommand{\remitem}[1]{\item\removed{#1}} |
19 | 36 |
|
20 | 37 | \newcommand{\ednote}[1]{\textcolor{noteclr}{[Editor's note: #1] }} |
21 | | -% \newcommand{\ednote}[1]{} |
22 | 38 |
|
23 | | -\newenvironment{addedblock} |
24 | | -{ |
25 | | -\color{addclr} |
26 | | -} |
27 | | -{ |
28 | | -\color{black} |
29 | | -} |
30 | | -\newenvironment{removedblock} |
31 | | -{ |
32 | | -\color{remclr} |
33 | | -} |
34 | | -{ |
35 | | -\color{black} |
36 | | -} |
| 39 | +\newenvironment{addedblock}{\color{addclr}}{\color{black}} |
| 40 | +\newenvironment{removedblock}{\color{remclr}}{\color{black}} |
37 | 41 |
|
38 | 42 | %%-------------------------------------------------- |
39 | 43 | %% Grammar extraction. |
| 44 | +%%-------------------------------------------------- |
40 | 45 | \def\gramSec[#1]#2{} |
41 | 46 |
|
42 | 47 | \makeatletter |
|
50 | 55 |
|
51 | 56 | %%-------------------------------------------------- |
52 | 57 | % Escaping for index entries. Replaces ! with "! throughout its argument. |
| 58 | +%%-------------------------------------------------- |
53 | 59 | \def\indexescape#1{\doindexescape#1\stopindexescape!\doneindexescape} |
54 | 60 | \def\doindexescape#1!{#1"!\doindexescape} |
55 | 61 | \def\stopindexescape#1\doneindexescape{} |
56 | 62 |
|
57 | 63 | %%-------------------------------------------------- |
58 | 64 | %% Cross references. |
| 65 | +%%-------------------------------------------------- |
59 | 66 | \newcommand{\addxref}[1]{% |
60 | 67 | \glossary[xrefindex]{\indexescape{#1}}{(\ref{\indexescape{#1}})}% |
61 | 68 | } |
|
66 | 73 | % number, a name, and a short tag. The depth is an integer in |
67 | 74 | % the range [0,5]. (If it proves necessary, it wouldn't take much |
68 | 75 | % programming to raise the limit from 5 to something larger.) |
| 76 | +%%-------------------------------------------------- |
69 | 77 |
|
70 | 78 | % Set the xref label for a clause to be "Clause n", not just "n". |
71 | 79 | \makeatletter |
|
112 | 120 |
|
113 | 121 | %%-------------------------------------------------- |
114 | 122 | % Indexing |
| 123 | +%%-------------------------------------------------- |
115 | 124 |
|
116 | 125 | % Layout of general index |
117 | 126 | \newcommand{\rSecindex}[2]{\section*{#2}\pdfbookmark[1]{#2}{pdf.idx.#1.#2}\label{idx.#1.#2}} |
|
201 | 210 |
|
202 | 211 | %%-------------------------------------------------- |
203 | 212 | % General code style |
| 213 | +%%-------------------------------------------------- |
204 | 214 | \newcommand{\CodeStyle}{\ttfamily} |
205 | 215 | \newcommand{\CodeStylex}[1]{\texttt{#1}} |
206 | 216 |
|
|
214 | 224 | \newcommand{\term}[1]{\textit{#1}} |
215 | 225 | \newcommand{\gterm}[1]{\GrammarStylex{#1}} |
216 | 226 | \newcommand{\fakegrammarterm}[1]{\gterm{#1}} |
217 | | -\newcommand{\keyword}[1]{\tcode{#1}\indextext{\idxcode{#1}}} |
| 227 | +\newcommand{\keyword}[1]{\tcode{#1}\indextext{\idxcode{#1}}} % macro length: 8 |
218 | 228 | \newcommand{\grammarterm}[1]{\indexgram{\idxgram{#1}}\gterm{#1}} |
219 | 229 | \newcommand{\grammartermnc}[1]{\indexgram{\idxgram{#1}}\gterm{#1\nocorr}} |
220 | 230 | \newcommand{\regrammarterm}[1]{\textit{#1}} |
221 | | -\newcommand{\placeholder}[1]{\textit{#1}} |
222 | | -\newcommand{\placeholdernc}[1]{\textit{#1\nocorr}} |
223 | | -\newcommand{\exposid}[1]{\tcode{\placeholder{#1}}} |
224 | | -\newcommand{\exposidnc}[1]{\tcode{\placeholdernc{#1}}\itcorr[-1]} |
| 231 | +\newcommand{\placeholder}[1]{\textit{#1}} % macro length: 12 |
| 232 | +\newcommand{\placeholdernc}[1]{\textit{#1\nocorr}} % macro length: 14 |
| 233 | +\newcommand{\exposid}[1]{\tcode{\placeholder{#1}}} % macro length: 8 |
| 234 | +\newcommand{\exposidnc}[1]{\tcode{\placeholdernc{#1}}\itcorr[-1]} % macro length: 10 |
225 | 235 | \newcommand{\defnxname}[1]{\indextext{\idxxname{#1}}\xname{#1}} |
226 | 236 | \newcommand{\defnlibxname}[1]{\indexlibrary{\idxxname{#1}}\xname{#1}} |
227 | 237 |
|
|
238 | 248 |
|
239 | 249 | %%-------------------------------------------------- |
240 | 250 | %% allow line break if needed for justification |
| 251 | +%%-------------------------------------------------- |
241 | 252 | \newcommand{\brk}{\discretionary{}{}{}} |
242 | 253 |
|
243 | 254 | %%-------------------------------------------------- |
244 | 255 | %% Macros for funky text |
| 256 | +%%-------------------------------------------------- |
245 | 257 | \newcommand{\Cpp}{\texorpdfstring{C\kern-0.05em\protect\raisebox{.35ex}{\textsmaller[2]{+\kern-0.05em+}}}{C++}} |
246 | 258 | \newcommand{\CppIII}{\Cpp{} 2003} |
247 | 259 | \newcommand{\CppXI}{\Cpp{} 2011} |
|
259 | 271 |
|
260 | 272 | %%-------------------------------------------------- |
261 | 273 | %% States and operators |
| 274 | +%%-------------------------------------------------- |
262 | 275 | \newcommand{\state}[2]{\tcode{#1}\ensuremath{_{#2}}} |
263 | 276 | \newcommand{\bitand}{\ensuremath{\mathbin{\mathsf{bitand}}}} |
264 | 277 | \newcommand{\bitor}{\ensuremath{\mathbin{\mathsf{bitor}}}} |
|
462 | 475 |
|
463 | 476 | %%-------------------------------------------------- |
464 | 477 | %% Environments for code listings. |
| 478 | +%%-------------------------------------------------- |
465 | 479 |
|
466 | | -% We use the 'listings' package, with some small customizations. The |
467 | | -% most interesting customization: all TeX commands are available |
468 | | -% within comments. Comments are set in italics, keywords and strings |
| 480 | +% We use the 'listings' package, with some small customizations. |
| 481 | +% The most interesting customization: all TeX commands are available |
| 482 | +% within comments. Comments are set in italics, keywords and strings |
469 | 483 | % don't get special treatment. |
470 | 484 |
|
471 | 485 | \lstset{language=C++, |
|
530 | 544 |
|
531 | 545 | %%-------------------------------------------------- |
532 | 546 | %% Indented text |
| 547 | +%%-------------------------------------------------- |
533 | 548 | \newenvironment{indented}[1][] |
534 | 549 | {\begin{indenthelper}[#1]\item\relax} |
535 | 550 | {\end{indenthelper}} |
536 | 551 |
|
537 | 552 | %%-------------------------------------------------- |
538 | 553 | %% Library item descriptions |
| 554 | +%%-------------------------------------------------- |
539 | 555 | \lstnewenvironment{itemdecl} |
540 | 556 | { |
541 | 557 | \lstset{escapechar=@, |
|
562 | 578 |
|
563 | 579 | %%-------------------------------------------------- |
564 | 580 | %% Bnf environments |
| 581 | +%%-------------------------------------------------- |
565 | 582 | \newlength{\BnfIndent} |
566 | 583 | \setlength{\BnfIndent}{\leftmargini} |
567 | 584 | \newlength{\BnfInc} |
|
636 | 653 |
|
637 | 654 | %%-------------------------------------------------- |
638 | 655 | %% Environment for imported graphics |
| 656 | +%%-------------------------------------------------- |
639 | 657 | % usage: \begin{importgraphic}{CAPTION}{TAG}{FILE} |
640 | 658 |
|
641 | 659 | \newenvironment{importgraphic}[3] |
|
651 | 669 |
|
652 | 670 | %%-------------------------------------------------- |
653 | 671 | %% Definitions section for "Terms and definitions" |
| 672 | +%%-------------------------------------------------- |
654 | 673 | \newcommand{\nocontentsline}[3]{} |
655 | 674 | \newcommand{\definition}[2]{% |
656 | 675 | \addxref{#2}% |
|
0 commit comments