summaryrefslogtreecommitdiff
path: root/texmf/tex/latex/pessay/pessay.cls
blob: 19181ba1f430b15a4276e02e765f6e7046b8955b (plain)
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
%% ---- Sean's Pandoc essay document class, derived from his spwpaper
%% ---- class.  Some features of the spwpaper class have not yet been
%% ---- implemented here, such as endnotes and some maths symbols.

\ProvidesClass{pessay}

%% ---- Commands to set up line spacing.

\newcommand{\initialdouble}{%
  \RequirePackage[doublespacing]{setspace}%
  \setstretch{2}%
}
\newcommand{\startdouble}{%
  \doublespacing%
  \setstretch{2}%
}
\newcommand{\finishdouble}{\onehalfspacing}

\newcommand{\dspacefn}{}

\newcommand{\dspaceq}{\onehalfspacing}

%% ---- Document title

\newcommand{\dospwtitle}{\makeatletter\renewcommand{\maketitle}{\finishdouble\thispagestyle{plain}
  \begin{center}\textsf{\@title}


  \textsf{\@author}\ifthenelse{\equal{\@date}{}}{}{$\qquad\quad$}\textsf{\@date}

\end{center}\startdouble
}\makeatother}

%% ---- Command to set up enumeration

\newcommand{\enumsettings}{%
  \setenumerate[1]{label={\arabic*.},ref={(\arabic*)},itemindent=0.30in,labelsep=1em,itemsep=-1em,before=\vspace{-0.5em},after=\vspace{-0.5em}}%
}

%% ---- Options for our document class.

%% One-half spacing

\DeclareOption{onehalf}{%
  \renewcommand{\initialdouble}{%
    \RequirePackage{setspace}%
    \onehalfspacing%
  }%
  \renewcommand{\startdouble}{}%
}

%% Pseudo double spacing

\DeclareOption{pseudodouble}{%
  \renewcommand{\initialdouble}{%
    \RequirePackage[doublespacing]{setspace}%
    \onehalfspacing%
  }%
  \renewcommand{\startdouble}{\doublespacing}%
}

%% Single spacing

\DeclareOption{single}{%
  \renewcommand{\initialdouble}{%
    \RequirePackage{setspace}%
  }%
  \renewcommand{\startdouble}{}%
  \renewcommand{\finishdouble}{}%
}

%% Double spacing of footnotes

\DeclareOption{dspacefns}{%
  \renewcommand{\dspacefn}{%
    \renewcommand{\footnotelayout}{\doublespacing}%
    \newlength{\myfootnotesep}%
    \setlength{\myfootnotesep}{\baselineskip}%
    \addtolength{\myfootnotesep}{-\footnotesep}%
    \setlength{\footnotesep}{\myfootnotesep}%
  }%
}

%% Double spacing of quotations

\DeclareOption{dspaceqs}{\renewcommand{\dspaceq}{\doublespacing}}

%% A4 paper instead of (default) letter paper

\newcommand{\papersettings}{%
  \LoadClass[12pt,letterpaper]{article}%
  \RequirePackage[letterpaper,headheight=0.5in,margin=1in,nofoot]{geometry}%
}

\DeclareOption{a4paper}{%
  \renewcommand{\papersettings}{%
    \LoadClass[12pt,a4paper]{article}%
    \RequirePackage[a4paper,headheight=0.5in,margin=1in,nofoot]{geometry}%
  }%
}

\newcommand{\notesandrefs}[1]{\noteshere
  \bibhere{#1}}
\newcommand{\doendnotes}{
  \renewcommand{\footnote}[1]{\endnote{##1}}}
\DeclareOption{footnotes}{\renewcommand{\notesandrefs}[1]{\bibhere{#1}}\renewcommand{\doendnotes}{}}

%% Enable enum numbering resume

\DeclareOption{resume}{%
  \renewcommand{\enumsettings}{%
    \setenumerate[1]{resume,label={\arabic*.},ref={(\arabic*)},itemindent=0.30in,labelsep=1em,itemsep=-1em,before=\vspace{-0.5em},after=\vspace{-0.5em}}%
  }%
}

%% Disable my title and fix spacing around the standard title

\DeclareOption{normaltitle}{\makeatletter
  \renewcommand{\dospwtitle}{
    \xpatchcmd{\@maketitle}
              {\@title}
              {\vspace{-2.0cm}\@title}
              {}{}
    \makeatother}}

%% ---- Pass options to the article class and then load it with
%% ---- \papersettings (defined just above)

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\papersettings

%% ---- Load all the other packages we'll need

\initialdouble                  % defined above; loads setspace package
\RequirePackage{amsmath}        % load it before loading fonts
\RequirePackage{enumitem}
\RequirePackage[british]{babel}
\RequirePackage{newtxmath}
\RequirePackage{newtxtext}      % would be good to use 'osf' option for old style figures: see newtxdoc.pdf
\RequirePackage[sc,sf,bf,compact,medium]{titlesec}
\RequirePackage{textcomp}
\RequirePackage[norule,splitrule,stable,multiple]{footmisc}
\dspacefn
\RequirePackage{fnpct}
%% \RequirePackage[utf8]{inputenc}
%% \RequirePackage{ellipsis}
%% \RequirePackage{stmaryrd}
\RequirePackage{ifthen}
%% \RequirePackage[all]{nowidow}
\RequirePackage{fancyhdr}
\RequirePackage{relsize}       % for \smaller in quotation font size
\RequirePackage{xpatch}

%% ---- Useful enumerations

\enumsettings

%% ---- Sectioning

%% First define my custom sectioning command for essay sections

%% see http://tex.stackexchange.com/a/8755

\newcommand{\essaysection}[1]{%
  \par
  \ifthenelse{\equal{\thesection}{0}}{}{\bigskip}
  \pagebreak[2]%
  \refstepcounter{section}%
    \everypar={%
      {\setbox0=\lastbox}       % remove the indentation
      \thesection. $\quad$%
      \ifthenelse{\equal{#1}{}}{}{ \textsl{#1} $\quad$}
      \everypar={}%
    }%
  \ignorespaces
}

%% Now set up \section* to point to the old \section*, but \section to
%% point to my \essaysection.  This works well with pandoc-citeproc.

%% see http://tex.stackexchange.com/a/77906

\makeatletter
\let\latex@section\section
\def\section{\secdef\my@section{\latex@section*}}
\def\my@section[#1]#2{\essaysection{#2}}
\makeatother

%% ---- Headers and footers

\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\textsf{\thepage}}
\fancypagestyle{plain}{ %
  \fancyhf{} % remove everything
  \fancyhead[R]{\textsf{\thepage}}
  \renewcommand{\headrulewidth}{0pt} % remove lines as well
  \renewcommand{\footrulewidth}{0pt}}
\renewcommand{\headrulewidth}{0pt}

%% ---- Document title

\dospwtitle

%% ---- Style inline quotations

\expandafter\def\expandafter\quote\expandafter{\quote\dspaceq\smaller[0.5]}

%% ---- Lists

%% Try to bring item separation in line with line spacing

\let\tempone\enumerate
\let\temptwo\endenumerate
\renewenvironment{enumerate}{\tempone\addtolength{\itemsep}{0.5\baselineskip}}{\temptwo}