forked from chiehrosswang/TRB_LaTeX_tex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trbunofficial.cls
218 lines (186 loc) · 7.04 KB
/
trbunofficial.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
% Transportation Research Board conference paper template
% version 4.0
%
% David R. Pritchard, http://davidpritchard.org
% 1.0 - Mar. 2009
% 1.1 - Sep. 2011, fixes for captions
% 2.0 - Mar. 2012, Reorganized title page incl. automatic counters
% 2.1 - Jul. 2015, Automatic total word counter and more formattings
% 2.1.1 - Jan. 2016, Minor modifications and first uploaded to Github
% 2.1.1 - May. 2016, created a lite version for people to use directly on TeX without Sweave options
% 4.0 - Jul. 2019, updated template to be compatible with Overleaf and ShareLaTeX
% Official trb manual for authors:
% http://onlinepubs.trb.org/onlinepubs/AM/InfoForAuthors.pdf
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{trbunofficial}[2017/06/10 TRB latex template]
\LoadClass[titlepage, oneside, 12pt]{article}
\RequirePackage[tiny, rm, pagestyles]{titlesec}
\RequirePackage{enumitem}
\RequirePackage{ccaption}
\RequirePackage[fleqn]{amsmath}
\RequirePackage{mathptmx} % Times text series for text and math
% Some pdf conversion tricks? Unsure.
\RequirePackage[T1]{fontenc}
\RequirePackage{textcomp}
\RequirePackage[pagewise,mathlines]{lineno}
\RequirePackage{geometry}
\RequirePackage[sort&compress, numbers]{natbib}
\RequirePackage{xparse}
\RequirePackage{currfile}
\RequirePackage{totcount}
\DeclareOption{numbered}{%
\linenumbers%
}
\ProcessOptions\relax
% Vars
%------------------------------------------------------------------------------
\def\@AuthorHeaders{Name1, Name2 and Name3}
\newcommand{\AuthorHeaders}[1]{%
\def\@AuthorHeaders{#1}
}
% Page layout
%------------------------------------------------------------------------------
\geometry{textwidth=6.5in, textheight=9.0in}
\geometry{top=1in, left=1in}
\geometry{headheight=0.3in, headsep=0.2in}
% Text formatting
%------------------------------------------------------------------------------
\setlength{\parindent}{0.5in}
% Header
%------------------------------------------------------------------------------
\newpagestyle{main}{%
\sethead{\@AuthorHeaders}{}{\thepage}
}
\pagestyle{main}
% HEADINGS
%------------------------------------------------------------------------------
% Line spacing: 12pt before section titles
\renewcommand*{\refname}{\uppercase{References}}
\titleformat{\section}{\bfseries}{}{0pt}{\uppercase}
\titlespacing*{\section}{0pt}{12pt}{*0}
\titleformat{\subsection}{\bfseries}{}{0pt}{}
\titlespacing*{\subsection}{0pt}{12pt}{*0}
\titleformat{\subsubsection}{\itshape}{}{0pt}{}
\titlespacing*{\subsubsection}{0pt}{12pt}{*0}
% EQUATIONS
%------------------------------------------------------------------------------
\setlength{\mathindent}{0in}
% Number the equation environment
\let\oldequation\equation%
\let\oldendequation\endequation%
\renewenvironment{equation}{%
\linenomath\oldequation%
}{%
\oldendequation\endlinenomath%
}%
% LISTS
%------------------------------------------------------------------------------
% Adjust lists a little. Not quite perfectly fitting TRB style, but vaguely
% close at least.
\setlist[1]{labelindent=0.5in,leftmargin=*}
\setlist[2]{labelindent=0in,leftmargin=*}
\setlist{nosep} % eliminate extra verticle spacings between items
% CAPTIONS
%------------------------------------------------------------------------------
% Get the captions right. Authors must still be careful to use "Title Case"
% for table captions, and "Sentence case." for figure captions.
\renewcommand{\fnum@figure}{\bfseries FIGURE~\thefigure}
\renewcommand{\fnum@table}{\bfseries TABLE~\thetable}
\captiontitlefont{\bfseries \boldmath}
\captiondelim{\;}
%\precaption{\boldmath}
% CITATIONS
%------------------------------------------
% TRB uses an Author (num) citation style. I haven't found a way to make
% LaTeX/Bibtex do this automatically using the standard \cite macro, but
% this modified \trbcite macro does the trick.
\renewcommand{\cite}[1]{(\textit{\citenum{#1}})}
\renewcommand{\citep}[1]{\citeauthor{#1} (\textit{\citenum{#1}})}
\setcitestyle{round}
% Reduce spacing between bibliographic items
\setlength{\bibsep}{0pt plus 0.3ex}
% LINE NUMBERING
%------------------------------------------------------------------------------
% Adjust the fond of the line numbering
\renewcommand\linenumberfont{\normalfont\small}
% REFERENCES
% Remove square brackets from the numbering and add indentation to bibliography
% in the REFERENCES section
\renewcommand\@biblabel[1]{#1.\hspace{0.25in}}
% COUNTERS
%------------------------------------------------------------------------------
% TRB requires the total number of words, figures, and tables to be displayed
% on the title page. This is possible under the totcount and the xparse
% packages on CTAN.
%
% Note that a total word count is added in V 2.1 to print a single value that
% is calculated as: numberofwords + numberoffigures*250 + numberoftable*250
% Total world count solution from Tex.SX:
% https://tex.stackexchange.com/q/255940
% https://tex.stackexchange.com/q/448605
% default: 250 number of words per table
\def\@WordsPerTable{250}
\newcommand{\WordsPerTable}[1]{%
\def\@WordsPerTable{#1}
}
% TODO: there must be a better way to define this to avoid using 0
% Variable to control manual word counting
\def\@TotalWords{0}
\newcommand{\TotalWords}[1]{%
\def\@TotalWords{#1}
}
% From totcount package
\regtotcounter{table} %count tables
\regtotcounter{figure} %count figures
\newcounter{wordcounter}
\newcounter{totalwordcounter}
\newread\somefile%
\NewDocumentCommand{\quickwordcount}{s}{%
\immediate\write18{texcount -1 -sum -merge \currfilename > \currfilebase-words}%
\immediate\openin\somefile=\currfilebase-words%
\write18{rm \currfilebase-words}%
\read\somefile to \@@localdummy%
\immediate\closein\somefile%
\setcounter{wordcounter}{\@@localdummy}%
\IfBooleanF{#1}{%
\@@localdummy% print only if not starred version
}%
}
\newcommand{\totalwordcount}{%
\quickwordcount*
\setcounter{totalwordcounter}{\value{wordcounter}}%
\addtocounter{totalwordcounter}{\numexpr\@WordsPerTable*\totvalue{table}}%
\number\value{totalwordcounter}% Output the number
\renewcommand{\totalwordcount}{\number\value{totalwordcounter}}
}
% TODO: find better way than multiple hfill and break to get numbered empty
% lines. Is it really necessary to have empty lines numbered? Its just the way
% users of word deal with that.
\renewcommand{\maketitle}{%
\thispagestyle{empty}
\begin{flushleft}
{\large\bfseries\@title}\\
\hfill\break%
\hfill\break%
\hfill\break%
\@author\\
\hfill\break%
\hfill\break%
\if\@TotalWords 0
Word Count: \quickwordcount~words $+$ \total{table} table(s) $\times$ \@WordsPerTable\ $=$ \totalwordcount~words\\
\else
Word Count: \@TotalWords\ words $+$ \total{table} table(s) $\times$ \@WordsPerTable\ $=$ \the\numexpr\@TotalWords + \totvalue{table}*\@WordsPerTable~words\\
\fi
\hfill\break%
\hfill\break%
\hfill\break%
\hfill\break%
\hfill\break%
\hfill\break%
Submission Date: \trbdate
\end{flushleft}
\newpage
}
% Set date to be the last time possible anywhere on earth (GMT-12), which is exactly one day behind New Zealand's time zone (GMT+12).
\usepackage{advdate}
\newcommand{\trbdate}{{\AdvanceDate[-1]\today}}