forked from cplusplus/draft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyles.tex
346 lines (313 loc) · 11.9 KB
/
styles.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
%!TEX root = std.tex
%% styles.tex -- set styles for:
% chapters
% pages
% footnotes
%%--------------------------------------------------
%% create chapter styles
\makechapterstyle{cppstd}{%
\setlength{\beforechapskip}{\onelineskip}
\setlength{\afterchapskip}{\onelineskip}
\renewcommand{\chapternamenum}{}
\renewcommand{\chapnamefont}{\chaptitlefont}
\renewcommand{\chapnumfont}{\chaptitlefont}
\renewcommand{\printchapternum}{\chapnumfont\thechapter\quad}
\renewcommand{\afterchapternum}{}
}
\makechapterstyle{cppannex}{%
\setlength{\beforechapskip}{\onelineskip}
\setlength{\afterchapskip}{\onelineskip}
\renewcommand{\chapternamenum}{}
\renewcommand{\chapnamefont}{\chaptitlefont}
\renewcommand{\chapnumfont}{\chaptitlefont}
\renewcommand{\printchapternum}{\chapnumfont\centering\thechapter\protect\\}
\renewcommand{\afterchapternum}{}
}
%%--------------------------------------------------
%% create page styles
\makepagestyle{cpppage}
\makeevenhead{cpppage}{}{\textbf{\docno}}{}
\makeoddhead{cpppage}{}{\textbf{\docno}}{}
\makeevenfoot{cpppage}{\leftmark\\\mbox{}}{}{\copyright\,\textsc{ISO/IEC}\\\thepage}
\makeoddfoot{cpppage}{\leftmark\\\mbox{}}{}{\copyright\,\textsc{ISO/IEC}\\\thepage}
\makeatletter
\makepsmarks{cpppage}{%
\let\@mkboth\markboth
\def\chaptermark##1{\markboth{##1}{##1}}%
\def\sectionmark##1{\markboth{%
\ifnum \c@secnumdepth>\z@
\textsection\space\thesection
\fi
}{\rightmark}}%
\def\subsectionmark##1{\markboth{%
\ifnum \c@secnumdepth>\z@
\textsection\space\thesubsection
\fi
}{\rightmark}}%
\def\subsubsectionmark##1{\markboth{%
\ifnum \c@secnumdepth>\z@
\textsection\space\thesubsubsection
\fi
}{\rightmark}}%
\def\paragraphmark##1{\markboth{%
\ifnum \c@secnumdepth>\z@
\textsection\space\theparagraph
\fi
}{\rightmark}}}
\makeatother
\aliaspagestyle{chapter}{cpppage}
%%--------------------------------------------------
%% set heading styles for main matter
\newcommand{\beforeskip}{-.7\onelineskip plus -1ex}
\newcommand{\afterskip}{.3\onelineskip minus .2ex}
\setbeforesecskip{\beforeskip}
\setsecindent{0pt}
\setsecheadstyle{\large\bfseries\raggedright}
\setaftersecskip{\afterskip}
\setbeforesubsecskip{\beforeskip}
\setsubsecindent{0pt}
\setsubsecheadstyle{\large\bfseries\raggedright}
\setaftersubsecskip{\afterskip}
\setbeforesubsubsecskip{\beforeskip}
\setsubsubsecindent{0pt}
\setsubsubsecheadstyle{\normalsize\bfseries\raggedright}
\setaftersubsubsecskip{\afterskip}
\setbeforeparaskip{\beforeskip}
\setparaindent{0pt}
\setparaheadstyle{\normalsize\bfseries\raggedright}
\setafterparaskip{\afterskip}
\setbeforesubparaskip{\beforeskip}
\setsubparaindent{0pt}
\setsubparaheadstyle{\normalsize\bfseries\raggedright}
\setaftersubparaskip{\afterskip}
%%--------------------------------------------------
% set heading style for annexes
\newcommand{\Annex}[3]{\chapter[#2]{\textnormal{(#3)}\protect\\[3ex]#2\hfill[#1]}\relax\annexlabel{#1}}
\newcommand{\infannex}[2]{\addxref{#1}\Annex{#1}{#2}{informative}}
\newcommand{\normannex}[2]{\addxref{#1}\Annex{#1}{#2}{normative}}
%%--------------------------------------------------
%% set footnote style
\footmarkstyle{\smaller#1) }
%%--------------------------------------------------
% set style for main text
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}
% set style for lists (itemizations, enumerations)
\setlength{\partopsep}{0pt}
\newlist{indenthelper}{itemize}{1}
\newlist{bnflist}{itemize}{1}
\setlist[itemize]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt,
beginpenalty=10 }
\setlist[enumerate]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt}
\setlist[indenthelper]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt, label={}}
\setlist[bnflist]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt, label={},
leftmargin=\bnfindentrest, listparindent=-\bnfindentinc, itemindent=\listparindent}
%%--------------------------------------------------
%% set caption styles
\DeclareCaptionLabelSeparator{emdash}{ --- }
\captionsetup{justification=centering,labelsep=emdash,font+=bf}
\captionsetup[lstlisting]{justification=raggedright,singlelinecheck=false,font=normal}
%%--------------------------------------------------
%% set global styles that get reset by \mainmatter
\newcommand{\setglobalstyles}{
\counterwithout{footnote}{chapter}
\counterwithout{table}{chapter}
\counterwithout{figure}{chapter}
\renewcommand{\chaptername}{}
\renewcommand{\appendixname}{Annex }
}
%%--------------------------------------------------
%% change list item markers to number and em-dash
\renewcommand{\labelitemi}{---\parabullnum{Bullets1}{\labelsep}}
\renewcommand{\labelitemii}{---\parabullnum{Bullets2}{\labelsep}}
\renewcommand{\labelitemiii}{---\parabullnum{Bullets3}{\labelsep}}
\renewcommand{\labelitemiv}{---\parabullnum{Bullets4}{\labelsep}}
%%--------------------------------------------------
%% set section numbering limit, toc limit
\maxsecnumdepth{subparagraph}
\setcounter{tocdepth}{1}
%%--------------------------------------------------
%% override some functions from the listings package to avoid bad page breaks
%% (copied verbatim from listings.sty version 1.6 except where commented)
\makeatletter
\def\lst@Init#1{%
\begingroup
\ifx\lst@float\relax\else
\edef\@tempa{\noexpand\lst@beginfloat{lstlisting}[\lst@float]}%
\expandafter\@tempa
\fi
\ifx\lst@multicols\@empty\else
\edef\lst@next{\noexpand\multicols{\lst@multicols}}
\expandafter\lst@next
\fi
\ifhmode\ifinner \lst@boxtrue \fi\fi
\lst@ifbox
\lsthk@BoxUnsafe
\hbox to\z@\bgroup
$\if t\lst@boxpos \vtop
\else \if b\lst@boxpos \vbox
\else \vcenter \fi\fi
\bgroup \par\noindent
\else
\lst@ifdisplaystyle
\lst@EveryDisplay
\par\lst@beginpenalty % penalty is now configurable
\vspace\lst@aboveskip
\fi
\fi
\normalbaselines
\abovecaptionskip\lst@abovecaption\relax
\belowcaptionskip\lst@belowcaption\relax
\let\savedallowbreak\allowbreak
\let\allowbreak\relax
\lst@MakeCaption t% % neuter \allowbreak before non-existing top caption
\let\allowbreak\savedallowbreak
\lsthk@PreInit \lsthk@Init
\lst@ifdisplaystyle
\global\let\lst@ltxlabel\@empty
\if@inlabel
\lst@ifresetmargins
\leavevmode
\else
\xdef\lst@ltxlabel{\the\everypar}%
\lst@AddTo\lst@ltxlabel{%
\global\let\lst@ltxlabel\@empty
\everypar{\lsthk@EveryLine\lsthk@EveryPar}}%
\fi
\fi
% A section heading might have set \everypar to apply a \clubpenalty
% to the following paragraph, changing \everypar in the process.
% Unconditionally overriding \everypar is a bad idea.
% \everypar\expandafter{\lst@ltxlabel
% \lsthk@EveryLine\lsthk@EveryPar}%
\else
\everypar{}\let\lst@NewLine\@empty
\fi
\lsthk@InitVars \lsthk@InitVarsBOL
\lst@Let{13}\lst@MProcessListing
\let\lst@Backslash#1%
\lst@EnterMode{\lst@Pmode}{\lst@SelectCharTable}%
\lst@InitFinalize}
\def\lst@DeInit{%
\lst@XPrintToken \lst@EOLUpdate
\global\advance\lst@newlines\m@ne
\lst@ifshowlines
\lst@DoNewLines
\else
\setbox\@tempboxa\vbox{\lst@DoNewLines}%
\fi
\lst@ifdisplaystyle \par\removelastskip \fi
\lsthk@ExitVars\everypar{}\lsthk@DeInit\normalbaselines\normalcolor
\lst@MakeCaption b%
\lst@ifbox
\egroup $\hss \egroup
\vrule\@width\lst@maxwidth\@height\z@\@depth\z@
\else
\lst@ifdisplaystyle
% make penalty configurable
\par\lst@endpenalty
\vspace\lst@belowskip
\fi
\fi
\ifx\lst@multicols\@empty\else
\def\lst@next{\global\let\@checkend\@gobble
\endmulticols
\global\let\@checkend\lst@@checkend}
\expandafter\lst@next
\fi
\ifx\lst@float\relax\else
\expandafter\lst@endfloat
\fi
\endgroup}
\def\lst@NewLine{%
\ifx\lst@OutputBox\@gobble\else
\par
% add configurable penalties
\lst@ifeolsemicolon
\lst@semicolonpenalty
\lst@eolsemicolonfalse
\else
\lst@domidpenalty
\fi
% Manually apply EveryLine and EveryPar; do not depend on \everypar
\noindent \hbox{}\lsthk@EveryLine%
% \lsthk@EveryPar uses \refstepcounter which balloons the PDF
\fi
\global\advance\lst@newlines\m@ne
\lst@newlinetrue}
% new macro for empty lines, avoiding an \hbox that cannot be discarded
\def\lst@DoEmptyLine{%
\ifvmode\else\par\fi\lst@emptylinepenalty
\vskip\parskip
\vskip\baselineskip
% \lsthk@EveryLine has \lst@parshape, i.e., \parshape, which causes an \hbox
% \lsthk@EveryPar increments line counters; \refstepcounter balloons the PDF
\global\advance\lst@newlines\m@ne
\lst@newlinetrue}
\def\lst@DoNewLines{
\@whilenum\lst@newlines>\lst@maxempty \do
{\lst@ifpreservenumber
\lsthk@OnEmptyLine
\global\advance\c@lstnumber\lst@advancelstnum
\fi
\global\advance\lst@newlines\m@ne}%
\@whilenum \lst@newlines>\@ne \do
% special-case empty printing of lines
{\lsthk@OnEmptyLine\lst@DoEmptyLine}%
\ifnum\lst@newlines>\z@ \lst@NewLine \fi}
% add keys for configuring before/end vertical penalties
\lst@Key{beginpenalty}\relax{\def\lst@beginpenalty{\penalty #1}}
\let\lst@beginpenalty\@empty
\lst@Key{midpenalty}\relax{\def\lst@midpenalty{\penalty #1}}
\let\lst@midpenalty\@empty
\lst@Key{endpenalty}\relax{\def\lst@endpenalty{\penalty #1}}
\let\lst@endpenalty\@empty
\lst@Key{emptylinepenalty}\relax{\def\lst@emptylinepenalty{\penalty #1}}
\let\lst@emptylinepenalty\@empty
\lst@Key{semicolonpenalty}\relax{\def\lst@semicolonpenalty{\penalty #1}}
\let\lst@semicolonpenalty\@empty
\lst@AddToHook{InitVars}{\let\lst@domidpenalty\@empty}
\lst@AddToHook{InitVarsEOL}{\let\lst@domidpenalty\lst@midpenalty}
% handle semicolons and closing braces (could be in \lstdefinelanguage as well)
\def\lst@eolsemicolontrue{\global\let\lst@ifeolsemicolon\iftrue}
\def\lst@eolsemicolonfalse{\global\let\lst@ifeolsemicolon\iffalse}
\lst@AddToHook{InitVars}{
\global\let\lst@eolsemicolonpending\@empty
\lst@eolsemicolonfalse
}
% If we found a semicolon or closing brace while parsing the current line,
% inform the subsequent \lst@NewLine about it for penalties.
\lst@AddToHook{InitVarsEOL}{%
\ifx\lst@eolsemicolonpending\relax
\lst@eolsemicolontrue
\global\let\lst@eolsemicolonpending\@empty
\fi%
}
\lst@AddToHook{SelectCharTable}{%
% In theory, we should only detect trailing semicolons or braces,
% but that would require un-doing the marking for any other character.
% The next best thing is to undo the marking for closing parentheses,
% because loops or if statements are the only places where we will
% reasonably have a semicolon in the middle of a line, and those all
% end with a closing parenthesis.
\lst@DefSaveDef{41}\lstsaved@closeparen{% handle closing parenthesis
\lstsaved@closeparen
\ifnum\lst@mode=\lst@Pmode % regular processing mode (not a comment)
\global\let\lst@eolsemicolonpending\@empty % undo semicolon setting
\fi%
}%
\lst@DefSaveDef{59}\lstsaved@semicolon{% handle semicolon
\lstsaved@semicolon
\ifnum\lst@mode=\lst@Pmode % regular processing mode (not a comment)
\global\let\lst@eolsemicolonpending\relax
\fi%
}%
\lst@DefSaveDef{125}\lstsaved@closebrace{% handle closing brace
\lst@eolsemicolonfalse % do not break before a closing brace
\lstsaved@closebrace % might invoke \lst@NewLine
\ifnum\lst@mode=\lst@Pmode % regular processing mode (not a comment)
\global\let\lst@eolsemicolonpending\relax
\fi%
}%
}
\makeatother