-
Notifications
You must be signed in to change notification settings - Fork 3
/
academic-letter-template.tex
276 lines (230 loc) · 9.1 KB
/
academic-letter-template.tex
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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Academic Letter LaTeX and RMarkdown Structure %
% Author: Pedro Henrique Pereira Braga %
% %
% License: %
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Set the font size (11pt, for now) and paper size (e.g. letterpaper, a4paper)
\documentclass[11pt, letterpaper]{letter}
%----------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------
\usepackage{graphicx} % Required for including pictures
\usepackage{fancyhdr} % Allows the use of fancy headers and footers
\usepackage{microtype} % For typography improvement
\usepackage{url} % Allows the use of hyperlinks
\urlstyle{same} % Allows hyperlink fonts to be the same as the mainfont
\usepackage[hidelinks]{hyperref} % Allows the use of hyperlinks and
% removes the blue boxes around the link
\pagestyle{empty} % Removes headers and footers
\usepackage{setspace} % Allows the use of double spacing in the letter body
\setlength\parindent{1cm} % Paragraph indentation
% Create a new command for the horizontal rule in the document which allows
% thickness specification
\makeatletter
\def\@texttop{} % force the address to start above
\renewcommand*{\opening}[1]{\ifx\@empty\fromaddress
\thispagestyle{firstpage}%
{\raggedleft\@date\par}%
\else % home address
\thispagestyle{empty}%
{\raggedleft\begin{tabular}{l@{}}\ignorespaces
\fromaddress \\*[2\parskip]%
\@date \end{tabular}\par}%
\fi
%\vspace{2\parskip}% <-- Removed
%{\raggedright \toname \\ \toaddress \par}% <-- Removed
%\vspace{2\parskip}% <-- Removed
#1\par\nobreak}
\let\ps@empty\ps@plain
\let\ps@firstpage\ps@plain
\makeatother
%--------------------------------------------------------------------------
% FONTS
%--------------------------------------------------------------------------
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[quiet]{fontspec} % Allows the use of fontspec
\usepackage{txfonts} % Allows the use of Lato fonts
% Selecting Google's Lato font-family, as it is free to use
% Bold and italic were not working, so I defined them for the main font
% manually as follows:
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor,
BoldFont=Lato-Bold.ttf,
ItalicFont=Lato-LightItalic.ttf,
BoldItalicFont=Lato-BoldItalic.ttf
]
{Lato-Regular.ttf}
\newfontfamily\bodyfont
[BoldFont=Lato-Bold.ttf,
ItalicFont=Lato-LightItalic.ttf,
BoldItalicFont=Lato-BoldItalic.ttf]
{Lato-Regular.ttf}
\newfontfamily\thinfont[]{Lato-Light.ttf}
%----------------------------------------------------------------------------
% DOCUMENT MARGINS
%----------------------------------------------------------------------------
\usepackage{geometry} % Required for adjusting page dimensions
\geometry{
headheight = 0.8in, % Header height
top=1.5in, % Top margin
bottom=1.5cm, % Bottom margin
left=3cm, % Left margin
right=3cm, % Right margin
% showframe, % Uncomment to show how the type block is set on the page
}
%-----------------------------------------------------------------------------
% AUTHOR AND RECIPIENTS NEW COMMANDS AND DETAILS STRUCTURE
%-----------------------------------------------------------------------------
\newcommand{\authordetails}[1]{\renewcommand{\authordetails}{#1}}
\newcommand{\recipientdetails}[1]{\renewcommand{\recipientdetails}{#1}}
%-----------------------------------------------------------------------------
% HEADER STRUCTURE
%-----------------------------------------------------------------------------
\address{
% Include the author's details on the right side of the page under the line
\raggedleft{
\footnotesize{ % Use a smaller font size
$author$\\ % Author name
\authordetails\\
\hspace{1mm}
}
}
\vspace{-0.05\textheight} % Move the date and letter content up
}
%------------------------------------------------------------------------------
% COMPOSE THE ENTIRE HEADER
%------------------------------------------------------------------------------
\renewcommand{\opening}[1]{
{\fromaddress
\vspace{0.05\textheight}\\ % Print the sender's address here and add some whitespace to allow the printing of the date
\raggedleft{$date$} % Include the date, aligned to the right
\par % par
}
{\raggedright
\toname\\
\toaddress
\par} % Print the recipient's name and adress
\vspace{0.25cm} % White vertical space after recipient's address
\noindent #1 % Following this, insert the opening info
}
%------------------------------------------------------------------------------
% SIGNATURE STRUCTURE
%------------------------------------------------------------------------------
% The signature is a combination of the author's name, title and institution
\signature{$author$, $from_professional_title$\\
$from_institution$}
% I will later combine the option of inserting a signature within it
\renewcommand{\closing}[1]{
\vspace{2.5mm} % Some whitespace after the letter content and before the signature
\noindent % Stop paragraph indentation
\hspace*{\longindentation} % Move the signature right to the value of \longindentation
\parbox{\indentedwidth}{
\raggedright
#1 % Print the signature text
\vskip 1.65cm % Whitespace between the closing text and author's name for a physical signature
\fromsig % Prints the value of \signature{}, i.e. author name and title
}
}
%-------------------------------------------------------------------------------
% AUTHOR'S INFORMATION
%-------------------------------------------------------------------------------
\authordetails{
$from_position$\\
\thinfont{$from_department$\\ % Sender's department/institution
$from_institution$\\
$from_address$\\ % Sender's address
$from_city$, $from_state_province$\\ % Sender's city, state or province,
$from_postalcode$\\ % postal code
$from_country$}
}
%------------------------------------------------------------------------------
% RECIPIENT'S INFORMATION
%------------------------------------------------------------------------------
\recipientdetails{
$to_professional_title$ $to_name$\\
\thinfont{
$if(to_department)$
$to_department$\\
$endif$
$if(to_institution)$
$to_institution$\\
$endif$
$if(to_address)$
$to_address$\\
$endif$
$to_city$, $to_state_province$\\
$if(to_postal_code)$
$to_postal_code$\\
$endif$
$if(to_country)$
$to_country$
$endif$}
$if(subject)$
\\~\\
\bodyfont{Subject: $subject$}
$endif$
}
%------------------------------------------------------------------------------
% HEADER CONTENTS
%------------------------------------------------------------------------------
\fancypagestyle{firstpage}{
\fancyhf{}
\fancyhead[L]{
\includegraphics[height=0.6in, keepaspectratio=true]{$from_institution_logo$}
}
\fancyhead[R]{$author$\\
\footnotesize{
$from_email$\\ % Sender's email address
$from_personal_website$ \\ % Sender's URL
$from_phone$ % Sender's phone number
}
}
}
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[L]{
\includegraphics[height=0.6in, keepaspectratio=true]{$from_institution_logo$}
}
\fancyhead[R]{$author$\\
\footnotesize{
$from_email$\\ % Sender's email address
$from_personal_website$ \\ % Sender's URL
$from_phone$ % Sender's phone number
}
}
}
\fancypagestyle{empty}{
\fancyhf{}
\fancyhead[L]{
\includegraphics[height=0.6in, keepaspectratio=true]{$from_institution_logo$}
}
\fancyhead[R]{$author$\\
\footnotesize{
$from_email$\\ % Sender's email address
$from_personal_website$ \\ % Sender's URL
$from_phone$ % Sender's phone number
}
}
}
%------------------------------------------------------------------------------
\pagestyle{plain}
\begin{document}
%------------------------------------------------------------------------------
% TO ADDRESS
%------------------------------------------------------------------------------
\begin{letter}{\recipientdetails}
%------------------------------------------------------------------------------
% LETTER CONTENT
%------------------------------------------------------------------------------
\opening{$opening_greeting$}
\begin{doublespacing}
$body$
\end{doublespacing}
\closing{$closing_greeting$}
%------------------------------------------------------------------------------
\end{letter}
\end{document}