-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainDocument.tex
279 lines (195 loc) · 10.1 KB
/
mainDocument.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
277
278
279
%%%%%%%%%%%%%%%% Preamble begins %%%%%%%%%%%%%%%%
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % needed for figures
\usepackage{amsmath} % needed to type beautiful math
\bibliographystyle{elsarticle-num} % a type of bibliography format
%% Some customization here
% needed to have subcaptions with letters in figures
\usepackage{subfig}
\usepackage{subfloat}
\renewcommand*\thesubfloatfigure{\themainfigure(\alph{subfloatfigure})}
\graphicspath{{figures/}}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple,listofformat=subsimple}
\renewcommand\thesubfigure{(\alph{subfigure})}
%% end of customization
\usepackage{hyperref} % needed to insert hyperref (internal to document) and hyperlinks (urls)
\hypersetup{colorlinks=true,citecolor=blue,linkcolor=blue} % for rendering hyperref and hyperlinks in blue so that they stand out more
\urlstyle{same}
\title{Postdoc Tutorial: Intro on \LaTeX}
\author{Valeria Barra}
\date{\today}
%%%%%%%%%%%%%%%% Preamble ends %%%%%%%%%%%%%%%%%%%%%
%---------------------------------------------%
%%%%%%%%%%%% Actual document body begins %%%%%%%%%%%%
%% Begin document
\begin{document}
\maketitle
\tableofcontents
% similarly, you can create:
\listoffigures
\listoftables
% this command pushes the next content on the next page
\clearpage
% Note: In two-sided printing, \cleardoublepage also makes the next page of content a right-hand page, an odd-numbered page, if necessary inserting a blank page
%% Introduction
%\section[Introduction]{Introduction}
% compare to:
\section*{Introduction} % this prevents this section from being listed and enumerated in the table of contents
This is an introduction to \LaTeX!
% Notice that every time we leave a blank line, we tell LaTeX to go on a new line and start a new paragraph. The new paragraph will be automatically indented.
But what is \LaTeX? And what is \TeX?
I like this answer from \url{https://tex.stackexchange.com/questions/49/what-is-the-difference-between-tex-and-latex}:
\vspace{\baselineskip} % this inserts a blank line for separation of paragraphs
\noindent ``In short \TeX is all about formatting, for document/template designers, while \LaTeX is all about content, for document writers.
\noindent \TeX is a typesetting system. It provides many commands which allow you to specify the format of your document with great detail (e.g. font styles, spacing, kerning, ligatures, etc.), and has specialized algorithms to compute the optimal flow of text in your document (e.g. where to cut lines, pages, etc.). \TeX is all about giving you powerful algorithms and commands to specify even the tiniest detail to make your documents look pretty.
\noindent \LaTeX is a set of macros built on top of \TeX. The idea behind \LaTeX is to shift the focus from the format to the content of your document. In LaTeX commands are all about giving a structure to the content of your document (e.g. sections, emphasis, tables, indices, etc.). In \LaTeX you just say \texttt{\textbackslash section[...]\{...\}} instead of: selecting a larger font, a different font style, and inserting appropriate spaces before and after the section heading. As LaTeX is built on top of TeX you also get, of course, a beautiful document as your output; but, more importantly, your source input can also be well structured, easier to read (and \emph{write}!) for humans.''
\vspace{\baselineskip} % this inserts a blank line for separation of paragraphs
One of my favorite references from undergrad is \cite{NotSoShortIntro}.
%% Section 2 (the first one is the Introduction, if we haven't used the "*")
\section[Section short title]{Section long title}
This is the first section of our document.
I think we need a subsection.
\subsubsection[Subsubsec. short title]{Subsubsection long title}\label{MySubsubsection}
I think we need a subsubsection.
%% Section 3
\section[Section short title]{Section long title}
Now let's start another section. Let's reference something that I said in section \ref{MySection} and elaborated in section \ref{MySubsubsection}.
\subsection[Subsec. short title]{Subsection long title}\label{MySection}
% an empty line creates a newline
Let's start a new line. % this gets automatically indented
% what if I want a new paragraph not to be indented?
% \noindent forces no indentation
\noindent Let's start a new line that is not automatically indented.
Let's add some vertical spacing.
\texttt{\textbackslash vspace\{\textbackslash baselineskip\}} inserts a blank line, i.e.,~allows you to skip a line with line-spacing given by your current font size.
\vspace{\baselineskip} % this inserts a blank line for separation of paragraphs
first line \smallskip,
second line \medskip,
third line \bigskip or
a fixed vertical spacing \vspace{1cm}
of 1 cm. % Note: our first math-mode so far. We include inline math-mode in single $ symbols. The number displayed in math-mode is aesthetically better than in non-math-mode
\vspace{0.5cm}
There are several units in \LaTeX to express spacing. Let's check this \href{https://www.overleaf.com/learn/latex/Lengths_in_LaTeX}{link}.
\vspace{\baselineskip}
Let's look at horizontal spacing. In normal text mode, you can use \mbox{\textbackslash hspace\{ \dots \}} with any desired length.
Some text here \hspace{2cm} some other text here.
In math mode:
\textbackslash quad space equal to the current font size (= 18 mu)
\textbackslash, 3/18 of \quad (= 3 mu)
\textbackslash: 4/18 of \quad (= 4 mu)
\textbackslash; 5/18 of \quad (= 5 mu)
\textbackslash! -3/18 of \quad (= -3 mu)
``\textbackslash \,'' (space after backslash) equivalent of space in normal text
\textbackslash qquad twice of \textbackslash quad (= 36 mu)
\vspace{\baselineskip}
Example:
\begin{align}\label{SpacingExample}
f(x) =& x^2\! +3x\! +2 \\
f(x) =& x^2+3x+2 \\
f(x) =& x^2\, +3x\, +2 \\
f(x) =& x^2\: +3x\: +2 \\
f(x) =& x^2\; +3x\; +2 \\
f(x) =& x^2\ +3x\ +2 \\
f(x) =& x^2\quad +3x\quad +2 \\
f(x) =& x^2\qquad +3x\qquad +2
\end{align}
\clearpage % forces the print of all floats (figures and tables) that could not fit and starts the next paragraph in a new page
% a similar command, \cleardoublepage forces all the floats (tables and images) to be printed and, in a two-sided document always starts the next page on the odd page
%% Section 4
\section[Another section short title]{Another section long title}
% let's create a boring table
% the table environment is needed if you want to caption and reference the table later
\begin{table}[t] % [t] places it at top of page
\begin{tabular}{ l c r }
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{tabular}
\caption{A very boring table of numbers, not centered in the page.}
\end{table}
\begin{table}[t] % [t] places it at top of page
\centering % this centers everything within this environment
\begin{tabular}{ l | c | r }
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{tabular}
\caption{A very boring table of numbers, with column separators and centered in the page.}
\end{table}
\begin{table}[ht] % [h] places it here, [ht] is here-top, a bit more elegant
% when LaTeX is stubborn, try "h!" for "really here!"
\centering % this centers everything within this environment
\begin{tabular}{ |l | c | r| }
\hline
1 & 2 & 3 \\
\hline
4 & 5 & 6 \\
\hline
7 & 8 & 9 \\
\hline
\end{tabular}
\caption{A very boring table of numbers, with column and row separators and centered in the page.}
\end{table}
\begin{table}[ht] % [h] places it here, [ht] is here-top, a bit more elegant
% when LaTeX is stubborn, try "h!" for "really here!"
\centering % this centers everything within this environment
\begin{tabular}{|r|l|}
\hline
7C0 & hexadecimal \\
3700 & octal \\ \cline{2-2} % \cline{i-j} partial horizontal line beginning in column i and ending in column j
11111000000 & binary \\
\hline \hline
1984 & decimal \\
\hline
\end{tabular}
\caption{A more complicated table.}
\end{table}
% a more advanced table
\begin{table}[ht] % [h] places it here, [ht] is here-top, a bit more elegant
% when LaTeX is stubborn, try "h!" for "really here!"
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multicolumn{3}{|c|}{Table of values of $k_{max}$} & \multicolumn{3}{|c|}{Table of values of $\omega_{1_{max}}$} \\ \hline
$h_0$ & $h_{\star}$ 0.01 & $h_{\star}$ 0.001 & $h_0$ & $h_{\star}$ 0.01 & $h_{\star}$ 0.001 \\ \hline
1 & 8.3850E-02 & 2.6700E-02 & 1 & 1.0317E-05 & 1.0602E-07 \\ \hline
0.5 & 2.3550E-01 & 7.5450E-02 & 0.5 & 1.2807E-04 & 1.3529E-06 \\ \hline
\end{tabular}
\caption{A more advanced table with multi-columns.}
\label{tab:ABoringTable}
\end{table}
\clearpage %gets rid of all floating objects (i.e., previous tables in this case) and starts the following text in a new page
Let's add some figures!
\vspace{3em}
\includegraphics[scale=0.5]{Images/CUBoulderLogo.png}
\vspace{3em}
The top figure is a figure without a \texttt{figure} environment, so it doesn't have a label (i.e., I cannot reference it later) and a caption.
\begin{figure}[h!]
\centering
\includegraphics[width=0.49\linewidth]{Images/CUBoulderLogo.png}
\caption{This now can be referenced, and it has a very nice caption.}
\label{fig:CuLogo}
\end{figure}
Let's add two figures side by side:
\begin{figure}[h!]
\centering
\includegraphics[width=0.5\linewidth]{Images/Stintino.jpg}
\hspace{2em} % some space in between
\includegraphics[width=0.4\linewidth]{Images/Minion.jpg}
\caption{Sardinia, Italy on the left; a minion on the right.}
\label{fig:SardiniaAndMinion}
\end{figure}
Now let's add two figures side by side, but in which I can use a subcaption (so I do not need to specify left/right in the caption). For this command I need a bit of work in the preamble.
\begin{figure}
\centering
\subfloat[]{\includegraphics[width=0.35\linewidth]{Images//Minion.jpg}\label{fig:Minion}}
\hfill % it separates the two objects, spanning the entire line
\subfloat[]{\includegraphics[width=0.5\linewidth]{Images/Stintino.jpg}\label{fig:Stintino}}
\caption{In \protect\subref{fig:Minion}, a Minion. In \protect\subref{fig:Stintino}, Sardinia, Italy.}
\end{figure}
\clearpage
%% Bibliography
\bibliography{References.bib}
\end{document}
%%%%%%%%%%%% Actual document ends %%%%%%%%%%%%