-
Notifications
You must be signed in to change notification settings - Fork 0
/
fhiso.sty
261 lines (225 loc) · 8.34 KB
/
fhiso.sty
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
% Basic fonts
\usepackage[no-math]{fontspec}
% Load the mono font first as it needs to be loaded before we set
% Ligatures=Tex, which this is what breaks straight quotes.
% Scale=MatchLowercase is needed or we get enormous monotype text.
% https://tex.stackexchange.com/questions/370468
\setmonofont{Noto Mono}[Scale=MatchLowercase]
\defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
% Noto fonts don't include small caps support. This fakes it.
% http://tex.stackexchange.com/a/225078/16883
\renewcommand\textsc[1]{\fauxschelper#1 \relax\relax}
\def\fauxschelper#1 #2\relax{%
\fauxschelphelp#1\relax\relax%
\if\relax#2\relax\else\ \fauxschelper#2\relax\fi%
}
\def\Hscale{.87}\def\Vscale{.75}\def\Cscale{1.00}
\def\fauxschelphelp#1#2\relax{%
\ifnum`#1>``\ifnum`#1<`\{\scalebox{\Hscale}[\Vscale]{\uppercase{#1}}\else%
\scalebox{\Cscale}[1]{#1}\fi\else\scalebox{\Cscale}[1]{#1}\fi%
\ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}
% Arabic support
\usepackage{ucharclasses}
\usepackage{ifthen}
\newfontfamily{\Arabicmainfont}[Script=Arabic, Scale=1]{Noto Naskh Arabic}
\newfontfamily{\Arabicmonofont}[Script=Arabic, Scale=0.8]{Noto Kufi Arabic}
\newcommand{\fhisoArabic}{%
\ifthenelse{\equal{\f@family}{NotoMono(0)}}{\Arabicmonofont}{\Arabicmainfont}%
}
\setTransitionsFor{Arabic}{\begingroup\fhisoArabic}{\endgroup}
% Hebrew support
% Note that Debian 'stretch' does not include Noto Serif Hebrew, hence
% using the sans serif version. Once Debian 'buster' has been released,
% the serif font will be available.
\newfontfamily{\Hebrewmainfont}[Script=Hebrew, Scale=1]{Noto Sans Hebrew}
\setTransitionsFor{Hebrew}{\begingroup\Hebrewmainfont}{\endgroup}
% Japanese support
% Note: this must come after \usepackage{ucharclasses} or we get spurious
% spaces within ``\texttt{...}''.
\usepackage{xeCJK}
\setCJKmainfont[Script=Hangul,Language=Korean]{Noto Sans CJK JP}
% Section title style
\usepackage{color}
\usepackage{xcolor}
\usepackage{needspace}
\usepackage{sectsty}
\definecolor{headcol}{HTML}{005A9C}
\newcommand\stdheadfont{\sffamily\color{headcol}\nohang}
\newcommand\titlefont{\bfseries\huge\stdheadfont}
\sectionfont{\needspace{7\baselineskip}\Large\stdheadfont}
\subsectionfont{\needspace{6\baselineskip}\large\stdheadfont}
\subsubsectionfont{\needspace{5\baselineskip}\normalsize\stdheadfont}
\usepackage{titling}
\renewcommand{\maketitlehooka}{\sffamily}
\newcommand\chapter[1]{}
% TODO: Remove this hard-coded path.
\usepackage{graphicx}
\graphicspath{{../website/}}
% Page headers and footers
\usepackage[a4paper]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\pagenumbering{arabic}
\fancyhf{}
\rhead{\itshape \@title}
\cfoot{\thepage}
\fancypagestyle{empty}{
\setlength\headheight{93pt}
\fancyhf{}
\chead{\includegraphics[scale=1]{logo.png}}
}
\usepackage{enumitem}
\setlist[itemize]{noitemsep, topsep=0pt, itemsep=0pt, parsep=0pt, label=---}
\setlist[enumerate]{noitemsep, topsep=0pt, itemsep=0pt, parsep=0pt}
\setlist[description]{style=nextline, topsep=0pt, itemsep=0.5em, parsep=0pt}
% Add leftmargin=2em to description to get narrower indents
\newcommand{\subtitle}[1]{%
\def\@subtitle{#1}%
\hypersetup{pdftitle=\@title: \@subtitle}%
\rhead{\itshape\@title: \@subtitle}%
}
% Count the number of authors
% https://tex.stackexchange.com/questions/391048
\newcounter{numauthors}
\def\count@and#1\and#2{%
\ifx#2\@nil\else
\stepcounter{numauthors}\expandafter\count@and\fi
}
\let\latex@author\author
\def\author#1{%
\stepcounter{numauthors}
\count@and#1\and\@nil
\latex@author{#1}
}
% Title page
\newcommand{\fhisotitle}{
\thispagestyle{empty}
\begin{center}
\vspace{1em}
{\titlefont{\@title}\ifdef{\@subtitle}{:\par\@subtitle}{}}
\vspace{2em}
{\large\sffamily\bfseries{\@date}}
\ifnum\value{numauthors}>0
\vspace{1em}
\renewcommand\and{\\}
\large\sffamily{\bfseries
\ifnum\value{numauthors}>1 Editors\else Editor\fi}:\\\@author
\fi
\vspace{1em}
\end{center}
}
\newcommand{\fhisoFinal}{%
% The 'bidi' package redefines \maketitle (which also breaks the 'titling'
% package). This defines it back to \fhisotitle.
% Unfortunately we can't just import 'bidi' now, because it needs to be
% imported after a bunch of other stuff in the template.
\usepackage{bidi}
\renewcommand{\maketitle}{\fhisotitle}%
% The default pandoc template defines and invokes \tightlist on all
% lists (enumerate, itemize, description). We'd rather configure
% these ourselves using the enumitem package.
\renewcommand{\tightlist}{}%
% Change hyperlink colours
\hypersetup{colorlinks=true,urlcolor=headcol,linkcolor=headcol}%
}
% Indent verbatim blocks by 2em
%\usepackage{fancyvrb}
%\renewenvironment{verbatim}{
% \VerbatimEnvironment
% % This is needed to remove extra space before CJK characters.
% % https://tex.stackexchange.com/questions/374469
% \CJKsetecglue{}
% \begin{Verbatim}[xleftmargin=2em]%
%}{\end{Verbatim}}
% The fancyvrb package doesn't do automatic line wrapping. Use
% the listings package instead. However that doesn't support Unicode
% properly. TODO: Investigate the minted package.
\let\verbatim\relax
\usepackage{listings}
\lstnewenvironment{verbatim}{\lstset{
basicstyle=\ttfamily,
xleftmargin=2em,
% These skips are determined empirically to match verbatim
aboveskip=-0.75em,
belowskip=-0.1em,
breaklines=true,
breakatwhitespace=true,
% colums=fullflexible and keepspaces=true uses the font's own kerning
columns=fullflexible,
keepspaces=true,
% postbreak is the indentation symbol
postbreak={\raisebox{0ex}[0ex][0ex]%
{\ensuremath{\color{gray}\rightarrow\space}}},
breakindent=1em
}}{}
\renewcommand{\quote}{\list{}{\rightmargin=\leftmargin\topsep=0pt}\item\relax}
% Classes that are inserted by pclasses.pl
% They're done in this roundabout way so that the use of an undefined
% class doesn't prevent compilation of the document.
\newcommand{\definefhisoclass}[3]{
\expandafter\def\csname fhisoopenclass@#1\endcsname{#2}
\expandafter\def\csname fhisocloseclass@#1\endcsname{#3}
}
\newcommand{\fhisoopenclass}[1]{%
\ifcsname fhisoopenclass@#1\endcsname%
\csname fhisoopenclass@#1\endcsname%
\fi%
}
\newcommand{\fhisocloseclass}[2]{%
\ifcsname fhisocloseclass@#1\endcsname%
\csname fhisocloseclass@#1\endcsname%
\fi%
}
% This is where we define FHISO classes.
% Syntax is much the same as for \newenvironment.
\usepackage{mdframed}
\mdfsetup{
leftmargin=2em,
linewidth=3pt,
rightline=false,
topline=false,
bottomline=false,
skipabove=1em,
skipbelow=0.25em
}
\definecolor{examplebg}{HTML}{E9FBE9}
\definecolor{exampleln}{HTML}{9999FF}
\newmdenv[backgroundcolor=examplebg,linecolor=exampleln]{examplebox}
\definefhisoclass{example}{\needspace{4\baselineskip}\begin{examplebox}%
{\color{headcol}\textit{Example} ---} \ignorespaces}%
{\end{examplebox}}
\definecolor{ednotebg}{HTML}{F9F0D4}
\definecolor{ednoteln}{HTML}{B77362}
\newmdenv[backgroundcolor=ednotebg,linecolor=ednoteln]{ednotebox}
\definefhisoclass{ednote}{\needspace{4\baselineskip}\begin{ednotebox}%
{\color{red}\textit{Editorial note} ---} \ignorespaces}%
{\end{ednotebox}}
\definecolor{notebg}{HTML}{F8F8F8}
\definecolor{noteln}{HTML}{C0C0C0}
\newmdenv[backgroundcolor=notebg,linecolor=noteln]{notebox}
\definefhisoclass{note}{\needspace{4\baselineskip}\begin{notebox}%
{\color{darkgray}\textit{Note} ---} \ignorespaces}%
{\end{notebox}}
% Prevent widows and orphans. (Note the default is 150.)
\widowpenalty=10000
\clubpenalty=10000
%\usepackage{hyperref}
%\hypersetup{colorlinks=true,urlcolor=blue,linkcolor=blue}
% Prevent bidi (v19.6) from putting numbers followed by a period backwards.
% This is not necessary now Debian squeeze has pulled in bidi version 20.x.
% \AtBeginDocument{\@Latintrue}
% Left-align all longtable environments (used by pandoc simple_table)
\usepackage{longtable,etoolbox}
% Set the spacing around tables to be the same as around boxes
\setlength{\LTpre}{1em}
\setlength{\LTpost}{0.25em}
\setlength{\LTleft}{2em} % 2em is the same as the note/example/ednote box
\pretocmd{\longtable}{%
% 13pt is \mdfsetup's rightmargin (10pt) + linewidth (3pt)
\addtolength\columnwidth{-2em}\addtolength\columnwidth{13pt}}{}{error}
% Captions are used in term definitions
\usepackage[labelformat=empty,singlelinecheck=false,margin=2em,skip=0.1em,
textfont={sf,bf,color=headcol}]{caption}
\pretocmd{\longtable}{\needspace{4\baselineskip}}{}{}