-
Notifications
You must be signed in to change notification settings - Fork 22
/
astro-bookshelf.cls
234 lines (205 loc) · 6.58 KB
/
astro-bookshelf.cls
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% astro-bookshelf.cls
%
% Formating class for notes posted on Open-Astrophysics-Bookshelf.
%
% Edward Brown
% Michigan State University
%
\def\fileversion{1.2}
\def\filedate{2021/01/14}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{astro-bookshelf}[\filedate, \fileversion]
\RequirePackage{ifxetex}
\RequirePackage{xifthen}
\typeout{%
Document Class: `astro-bookshelf' v\fileversion \space <\filedate>}
% Flag to indicate we are making a handout
\newboolean{@handout}
\setboolean{@handout}{false}
\DeclareOption{handout}{\setboolean{@handout}{true}}
% Define fonts. The option profonts specifies the use of Chapparal Pro, Raleway Medium,
% and Source Code Pro for the serif, san serif, and fixed width fonts.
\newboolean{@profonts}
\setboolean{@profonts}{false}
\DeclareOption{profonts}{\setboolean{@profonts}{true}}
\newboolean{@stix}
\setboolean{@stix}{false}
\DeclareOption{stix}{\setboolean{@stix}{true}}
\ProcessOptions
\ifthenelse{\boolean{@handout}}
{
\LoadClass{tufte-handout}
% \DeclareOption*{\PassOptionsToClass{\CurrentOption}{tufte-handout}}
}
{
\LoadClass{tufte-book}
% \DeclareOption*{\PassOptionsToClass{\CurrentOption}{tufte-book}}
}
\RequirePackage{natbib}
\RequirePackage{amssymb}
\ifxetex
\RequirePackage{mathspec}
\fi
\RequirePackage{graphicx}
\RequirePackage{wallpaper}
\RequirePackage{ccicons}
\RequirePackage{tcolorbox}
\RequirePackage{fancyvrb}
\ifxetex
\defaultfontfeatures{Scale=MatchLowercase}
\renewcommand{\allcapsspacing}[1]{{\addfontfeature{LetterSpace=20.0}#1}}
\renewcommand{\smallcapsspacing}[1]{{\addfontfeature{LetterSpace=5.0}#1}}
\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{#1}}}
\renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{#1}}}
\ifthenelse{\boolean{@profonts}}
{
\typeout{loading Chaparral Pro, Source Code Pro, and Raleway Medium}
\setmainfont[Mapping=tex-text]{Chaparral Pro}
\setmonofont[Mapping=tex-text]{Source Code Pro}
\setsansfont[Mapping=tex-text]{Raleway Medium}
\setmathsfont(Digits,Latin)[Numbers={Lining,Proportional}, Scale=MatchLowercase, Mapping=tex-text]{Chaparral Pro}
\setmathrm{Chaparral Pro}
\setmathtt{Source Code Pro}
}{
\typeout{loading Palatino, Courier, and Helvetica}
\setmainfont[Mapping=tex-text]{TeX Gyre Pagella}
\setmonofont[Mapping=tex-text]{TeX Gyre Cursor}
\setsansfont[Mapping=tex-text]{TeX Gyre Heros}
\setmathsfont(Digits,Latin)[Numbers={Lining,Proportional}, Scale=MatchLowercase, Mapping=tex-text]{TeX Gyre Pagella}
\setmathrm{TeX Gyre Pagella}
\setmathtt{TeX Gyre Cursor}
}
\ifthenelse{\boolean{@stix}}
{
\setmathsfont(Greek)[Scale=MatchLowercase,Mapping=tex-text]{STIXGeneral}
% for bold Greeks
\fontspec{STIXGeneral}
\SetSymbolFont{Greek:m:n}{bold}{TU}{\zf@family}{bx}{n}
\SetSymbolFont{Greek:m:it}{bold}{TU}{\zf@family}{bx}{it}
}{}
\fi
% settings for sidebar text boxes
\tcbuselibrary{breakable}
\tcbset{colback=yellow!5!white,fonttitle=\bfseries}
% for having inline author citations
\newcommand{\citetalt}[1]{\citeauthor{#1}\cite{#1}}
% for code listings
\fvset{numbers=left}
% we increase \@tempdima from 2em to 2.4em to accomodate the width of the figure numbers
\renewcommand{\@tufte@lof@line}[2]{%
% #1 is the figure/table number and its caption text
% #2 is the page number on which the figure/table appears
\leftskip 0.0em
\rightskip 0em
\parfillskip 0em plus 1fil
\parindent 0.0em
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima 2.4em
\advance\leftskip\@tempdima
\null\nobreak\hskip -\leftskip
{#1}\nobreak\qquad\nobreak#2%
\par%
}
\renewcommand*\l@figure{\@tufte@lof@line}
\renewcommand*{\listfigurename}{Figures}
\renewcommand*{\listtablename}{Tables}
% Offset box for inline exercises
\ifthenelse{\boolean{@handout}}
{
\newcounter{exercise}
}
{
\newcounter{exercise}[chapter]
\renewcommand{\theexercise}{\thechapter.\arabic{exercise}}
}
\newcommand{\listexercisename}{Exercises}
\newcommand\listofexercises{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listexercisename}}%
{\section*{\listexercisename}}%
\@starttoc{loe}%
}
% \newlistof[chapter]{exercise}{loe}{\listofexercises}
\newcommand{\exercisedescription}[1]{%
\addcontentsline{loe}{exercise}{\protect\numberline{\theexercise}{\ignorespaces #1}}
}
\newenvironment{exercisebox}[1][]{%
\vspace{\baselineskip}
\noindent\begin{minipage}{\linewidth}\small\raggedright
\refstepcounter{exercise}
\ifnum\value{exercise} = 1%
\addtocontents{loe}{\protect\addvspace{10\p@}}%
\fi
\setlength{\parindent}{1.0pc}
\noindent\rule[0.6ex]{\linewidth}{0.5pt}
\allcaps{exercise \theexercise---}
\exercisedescription{#1}}
{\noindent\rule[0.6ex]{\linewidth}{0.5pt}
\end{minipage}
}
\let\l@exercise\l@figure
% Environment for sidebar
\ifthenelse{\boolean{@handout}}
{
\newcounter{sidebar}
}
{
\newcounter{sidebar}[chapter]
\renewcommand{\thesidebar}{\thechapter.\arabic{sidebar}}
}
\newcommand{\listsidebarname}{Boxes}
\newcommand\listofsidebars{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listsidebarname}}%
{\section*{\listsidebarname}}%
\@starttoc{lob}%
}
\newcommand{\sidebardescription}[1]{%
\addcontentsline{lob}{sidebar}{\protect\numberline{\thesidebar}{\ignorespaces #1}}
}
\newenvironment{sidebar}[1][]{%
\vspace{\baselineskip}
\refstepcounter{sidebar}
\begin{tcolorbox}[breakable,title=Box \thesidebar\ #1,title after break=Box \thesidebar\ continued]
\ifnum\value{sidebar} = 1%
\addtocontents{lob}{\protect\addvspace{10\p@}}%
\fi
\sidebardescription{#1}\setlength{\parindent}{1.0pc}}
{\end{tcolorbox}
}
\let\l@sidebar\l@figure
% Environment for MESA exercises
\ifthenelse{\boolean{@handout}}
{
\newcounter{mesa}
}
{
\newcounter{mesa}[chapter]
\renewcommand{\themesa}{\thechapter.\arabic{mesa}}
}
\newcommand{\listmesaname}{MESA experiments}
\newcommand\listofmesa{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listmesaname}}%
{\section*{\listmesaname}}%
\@starttoc{lom}%
}
\newcommand{\mesadescription}[1]{%
\addcontentsline{lom}{mesa}{\protect\numberline{\themesa}{\ignorespaces #1}}
}
\newenvironment{mesaproject}[1][]{%
\vspace{\baselineskip}
\refstepcounter{mesa}
\section*{\raisebox{-0.015ex}{\includegraphics[height=1.4ex]{mesa_logo2}} Experiment \themesa--- #1}
\ifnum\value{mesa} = 1%
\addtocontents{lom}{\protect\addvspace{10\p@}}%
\fi
\mesadescription{#1}\setlength{\parindent}{1.0pc}}
{}
\let\l@mesa\l@figure