-
Notifications
You must be signed in to change notification settings - Fork 50
/
common-header.tex
313 lines (258 loc) · 9.8 KB
/
common-header.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
\documentclass{book}
\usepackage[quiet]{fontspec}
\usepackage[table,xcdraw,dvipsnames]{xcolor} % Used by spritegrid and others.
\usepackage[obeyspaces,spaces]{url}
\usepackage{longtable}
\usepackage{arydshln}
\usepackage{booktabs}
\usepackage{afterpage}
\usepackage{flushend}
\usepackage{titletoc}
\usepackage[toc]{appendix}
\usepackage{parskip}
\usepackage{graphicx,wrapfig}
\usepackage{float}
\usepackage{caption}
\usepackage{pdfpages}
\usepackage{tikzpagenodes}
\usepackage{imakeidx}
\usepackage[pagestyles,raggedright]{titlesec}
\usepackage[all]{nowidow}
\usepackage{etoolbox}
\usepackage{alphalph}
\usepackage{datetime}
\newdateformat{dateyear}{\THEYEAR}
% Change the hyperanchors to allow more than 26 appendices
\appto\appendix{
\renewcommand\thechapter{\AlphAlph{\value{chapter}}}%
}
\usepackage[bookmarks=true,linktoc=all]{hyperref}
\usepackage{tabularx}
\hypersetup{
colorlinks = true, %Colours links instead of ugly boxes
urlcolor = blue, %Colour for external hyperlinks
% Each main .tex file configures via \titleformat the \chapter command
% to do {\chapmtoc\insertminitoc} and \chapmtoc, as defined below, will
% use \hypersetup{linkcolor=white} to avoid blue-on-blue TOC links
% Besides, each main .tex file will issue the \tableofcontents command
% between \hypersetup{linkcolor=black} and \hypersetup{linkcolor=blue}
% This means however that if "blue" is modified here it must be modified
% in these files too.
linkcolor = blue, %Colour of internal links
citecolor = red %Colour of citations
}
\usepackage{aeb-minitoc}
\usepackage{fix-cm}
\usepackage{textpos}
\usepackage{enumitem}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,listings,skins,xparse}
%\usepackage{wrapfig}
\usepackage{needspace}
\usepackage{verbatim}
\usepackage{ean13isbn}
\usepackage{setspace}
% Use CHAPTER-PAGE page numbering to make it easier to modify chapters
% later, without messing up page number of the rest of the book.
\usepackage[auto]{chappg}
% Allow cross-references between the various books to the big The MEGA65 Book
\usepackage{xr}
\usepackage{varioref}
\usepackage{xparse}
\usepackage{colortbl}
\usepackage{adjustbox}
\externaldocument[M65Book-]{mega65-book}
% And a \ref alternative that checks if it needs to be a cross-reference to the
% MEGA65 Book instead.
\makeatletter
\newcommand{\bookref}[1]{%
\@ifundefined{r@#1}{%
{\em the MEGA65 Book}, \nameref{M65Book-#1} (\autoref{M65Book-#1})}{\autoref{#1}}%
}
\newcommand{\bookvref}[1]{%
\@ifundefined{r@#1}{%
{\em the MEGA65 Book}, \nameref{M65Book-#1} (\autoref{M65Book-#1})}{Chapter/Appendix \vref{#1}}%
}
\makeatother
% For fixed-width columns in register maps
\usepackage{array}
% Makes tables with double-ruled lines look better
\usepackage{hhline}
% Makes better use of space for reference tables in appendix
\usepackage{multicol}
% Shaded tables with alternate rows colored for better legibility
% Best used with larger tables rather than small tables
\usepackage{colortbl}
\usepackage{adjustbox}
\usepackage[strict]{changepage}
% \makecell command for forcing line breaks in table cells
\usepackage{makecell}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
% clear to left page for making two page tables starting on the odd page
\newcommand{\cleartoleftpage}{%
\clearpage
\ifodd\value{page}\hbox{}\newpage\fi
}
% Layout structures for acknowledgements pages
\input{elements/acknowledgements}
% For displaying Letter keys and the MEGA key
\input{elements/keys}
% For displaying print versions petscii character symbols
\input{elements/graphicsymbol}
% For Mega65 display of code, listings and screen activity
\input{elements/screenoutput}
% For MEGA65 screen shots with text flow
\input{elements/screenshots}
% For displaying sprite data in a grid
\input{elements/spritegrid}
% Don't number sections
\setcounter{secnumdepth}{0}
\renewcommand{\indexname}{INDEX}
\renewcommand{\appendixtocname}{APPENDICES}
\renewcommand{\appendixpagename}{APPENDICES}
\renewcommand{\appendixpage}{%
\clearpage\thispagestyle{empty}
\pagecolor{blue}
\begin{center}
{
\large
% Put a nice amount of vertical space before the title
\vspace*{2cm}
{\large\Huge\textcolor{white}{\bf{APPENDICES}}}\\
\vspace{\fill}
}
\end{center}
\newpage\pagecolor{white}\clearpage
}
% Commands for Style Guide entries
% \sgentry{itemid}{Item Name Text}{Description of the item...}
\makeatletter
\newenvironment{sgentry}[2]{
\needspace{4\baselineskip}
\phantomsection\def\@currentlabelname{#2}\label{sgentry:#1}{\bf #2}
\begin{adjustwidth}{1cm}{}
}{
\end{adjustwidth}
\vspace{3mm}
}
\makeatother
\newcommand{\sg}[1]{\nameref{sgentry:#1}}
\makeatletter\chardef\pdf@shellescape=\@ne\makeatother
\setcounter{tocdepth}{5}
% 1.0 cm is the distance from left of page to bullet point.
% 2.8 cm is a fudge-factor to make multi-line section names be correctly lined up.
% \@B{〈length〉} is the amount to indent prior to〈sec-num >
% \@F{〈fmt〉} is the formatting for the title heading
% \@P{〈fmt〉} is the formatting for the page number (〈pg-num〉).
\TOCLevels{chapter}{section}
\begin{minitocfmt}{\chapmtoc}
\declaretocfmt{section}{\@F{\color{white}\hypersetup{linkcolor=white}\hspace{1.0cm}\textbullet\hspace{0.25cm}\Large\bfseries}\@B{2.8cm}\@P{\mtocgobble}}
\declaretocfmt{section*}{\@F{\color{white}\hypersetup{linkcolor=white}\hspace{1.0cm}\textbullet\hspace{0.25cm}\Large\bfseries}\@B{2.8cm}\@P{\mtocgobble}}
\end{minitocfmt}
\input{fonts}
% Set margins for inner and outer pages in A5 book format
\ifdefined\printmanualbleed
\usepackage[noinfo, cam, width=6.08in, height=8.52in, center]{crop}
\fi
\ifdefined\printmanual
\usepackage[a5paper,nomarginpar,includemp,bottom=2cm,top=1cm,inner=1.8cm,outer=0.8cm, footskip = 1cm]{geometry}
\else
\usepackage[a5paper,nomarginpar,includemp,bottom=2cm,top=1cm,inner=1.0cm,outer=1.0cm, footskip = 1cm]{geometry}
\fi
% correct bad hyphenation here
\hyphenation{op-tical net-works semi-conduc-tor}
\makeindex[intoc]
\pagestyle{empty}
% macro for changing the verbatim font
\makeatletter
\newcommand{\verbatimfont}[1]{\def\verbatim@font{#1}}%
\makeatother
% \megabookstart : Book title page, copyright page, table of contents
%
% Usage:
% \megabookstart{BOOK TITLE}{Version string}
%
% Examples:
% \megabookstart{MEGA65 USER'S GUIDE}{2nd edition}
% \megabookstart{MEGA65 REFERENCE GUIDE}{WORK IN PROGRESS}
%
% Linebreaks \\ can be used within a title to get better formatting as desired.
% Do not put math or special symbols in the title.
\newcommand{\megabookstart}[2]{
\cleardoublepage
\pagenumbering{roman}
\begin{titlepage}
\pagecolor{blue}
\begin{center}
{
\large
\vspace*{2cm}
{\Huge\textcolor{white}{\bf{#1}}}\\
\vspace{\fill}
{\textcolor{white}
{Published by \\ the MEGA Museum of Electronic Games \& Art e.V., Germany.}}
}
\end{center}
\end{titlepage}
% Then the copyright notice page
\pagecolor{white}\textcolor{black}
\vfill
{#2}
%\index{copyright}
Copyright \copyright 2019 -- \dateyear{\today} by Paul Gardner-Stephen,
the MEGA Museum of Electronic Games \& Art e.V.,
and contributors.
This book is made available under the GNU Free Documentation
License v1.3, or later, if desired. This means that you are free to
modify, reproduce and redistribute this book, subject to
certain conditions. The full text of the GNU Free Documentation
License v1.3 can be found at
\url{https://www.gnu.org/licenses/fdl-1.3.en.html}.
Implicit in this copyright license, is the permission to duplicate
and/or redistribute this document in whole or in part for use in
education environments. We want to support the education of future
generations, so if you have any worries or concerns, please contact us.
\par\usdate\today
\newpagestyle{onlynumber}{\setfoot[][{\bf\small\thepage}][]
{} {\bf\small\thepage} {}}
\pagestyle{onlynumber}
\pagecolor{white}
\hypersetup{linkcolor=black}
\tableofcontents
\hypersetup{linkcolor=blue}
\cleardoublepage
\pagenumbering{arabic}
}
% Define color "RED" so that titles can use "red" without worrying about \uppercase.
\colorlet{RED}{red}
\newcommand*{\justifyheading}{\raggedleft}
\definecolor{headingblue}{rgb}{0.5,0.5,1}
\titleclass{\part}{top}
\titleformat{\part}[display]
{\thispagestyle{empty}\pagecolor{blue}\normalfont\huge\bfseries\justifyheading}
{\textcolor{white}{\fontsize{50}{65}\selectfont\bf{PART}\quad{\fontsize{100}{130}\selectfont \bf{\serifed\thepart}}}}
{20pt}
{\Huge\textcolor{white}}
[\newpage\pagecolor{white}\textcolor{black}]
\titleformat{\chapter}[display]
{\thispagestyle{empty}\pagecolor{blue}\normalfont\huge\bfseries\justifyheading}
{\textcolor{white}{\MakeUppercase{\chaptertitlename}\quad{\fontsize{100}{130}\selectfont \bf\thechapter}}}
{20pt}
{\Huge\textcolor{white}}
[{\chapmtoc\insertminitoc}\newpage\pagecolor{white}\textcolor{black}\cleardoublepage]
\titleformat{\section}[display]
{\raggedright}
{\thesection}
{20pt}
{\huge\bf\color{headingblue}\uppercase}
[\color{black}]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\raggedbottom
% relax word wrapping with sloppy
\sloppy
% reduce overfull \hbox warnings
\hfuzz=5pt
\setstretch{0.9}