summaryrefslogtreecommitdiff
path: root/texmf/tex/latex/pessay/pessay.cls
blob: 08d2d0b3e936af19fb9920736da758ca0723ecb2 (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
%% ---- 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}

%% ---- 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}{}%
}

%% 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}{}}


%% ---- 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

\RequirePackage{amsmath}        % load it before loading fonts
\RequirePackage{enumitem}
\RequirePackage[british]{babel}
\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}
%% \RequirePackage[utf8]{inputenc}
%% \RequirePackage{ellipsis}
%% \RequirePackage{stmaryrd}
\RequirePackage{ifthen}
%% \RequirePackage[all]{nowidow}
\RequirePackage{fancyhdr}
\initialdouble                  % defined above, loads setspace package

%% ---- Useful enumerations

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

%% ---- 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
  \renewcommand{\headrulewidth}{0pt} % remove lines as well
  \renewcommand{\footrulewidth}{0pt}}
\renewcommand{\headrulewidth}{0pt}

%% ---- Document title

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

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

\end{center}\startdouble
}\makeatother