-
Notifications
You must be signed in to change notification settings - Fork 0
/
learn_LaTex.tex
402 lines (335 loc) · 14.7 KB
/
learn_LaTex.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
\documentclass[12pt, letterpaper]{article}
\usepackage[]{inputenc}
\usepackage{graphicx}
\usepackage{verbatim} % we use comment command to excute mutiple comments in latex, OR we can use \usepackage{comment}.
\usepackage{amssymb} % this package contains some special mathematical symbols.
\usepackage{wrapfig}
\usepackage{tabu}
\graphicspath{{F:/Projects/LaTex}} % \graphicspath{ {./path1/}{./path2/} }
\title{First document}
\author{Zhihai He \thanks{thanks information in here.} \and MindExp \thanks{funded by the ShareLaTeX team.}}
\date{July 2018}
\begin{document}
\begin{titlepage} % title page in latex.
\maketitle
\end{titlepage}
\tableofcontents
First document. This is a simple example, with no % there are two ways to start a new line in latex, using a blank line or \par.
extra parameters or packages included.
\textbf{Centering the Text}
\begin{center} % equivalent to \centering, but the latter command will be working from the point where it's inserted down to the end of the document, unless another switch command is inserted, the same as flushelft with \raggedleft, and flushright with \raggedright.
Example 1: The following paragraph (given in quotes) is an
example of Center Alignment using the center environment.
``LaTeX is a document preparation system and document markup
language. LaTeX uses the TeX typesetting program for formatting
its output, and is itself written in the TeX macro language. \par % the next will start a new paragraph
LaTeX is not the name of a particular editing program, but
refers to the encoding or tagging conventions that are used
in LaTeX documents".
\end{center}
\textbf{Flushing Left the Text}
\begin{flushleft}
``LaTeX is a document preparation system and document markup
language. LaTeX uses the TeX typesetting program for formatting
its output, and is itself written in the TeX macro language.
LaTeX is not the name of a particular editing program, but refers
to the encoding or tagging conventions that are used in LaTeX documents".
\end{flushleft}
\textbf{Flushing Right the Text}
\begin{flushright}
``LaTeX is a document preparation system and document markup
language. LaTeX uses the TeX typesetting program for formatting
its output, and is itself written in the TeX macro language.
LaTeX is not the name of a particular editing program, but refers
to the encoding or tagging conventions that are used in LaTeX documents".
\end{flushright}
% This \textbf{•} here is a comment. It will not be printed in the document.
\textbf{Bold, italics and underlining}
Some of the \textbf{greatest} discoveries in \underline{science} were made by \textbf{\textit{accident}}.
% What the \emph command actually does with its argument depends on the context.
Some of the greatest \emph{discoveries} in science were made by accident.
\textit{Some of the greatest \emph{discoveries} in science were made by accident.}
\textbf{Some of the greatest \emph{discoveries} in science were made by accident.}
\textbf{Adding images}
\begin{center}
\begin{comment}
\includegraphics[scale=1.5]{lion-logo} % the extra parameter scale=1.5 will do exactly that, scale the image 1.5 of its real size.
\includegraphics[width=3cm, height=4cm]{lion-logo} % scale the image to a some specific width and height.
\includegraphics[width=\textwidth]{universe} % make a picture the same width as the text.
\includegraphics[scale=1.2, angle=45]{lion-logo} % The parameter angle=45 rotates the picture 45 degrees counter-clockwise.
\end{comment}
\includegraphics[width=3.5in]{./2018-06-26_222331} % Chinese can not be contained in the file path.
\begin{figure}[h] % The figure environment will position the figure in a such way that it fits the flow of the document, the brackets set the position of the figure[h | t | b | p | ! | H].
\centering
\includegraphics[scale=0.6]{./2018-06-27_164120}
\caption{a nice plot} % you may expect this command sets the caption for the Ògure.
\label{fig:plot} % If you need to refer the image within your document, set a label with this command.
\end{figure}
\end{center}
As you can see in the figure \ref{fig:plot}, It is an example of sigmoid function. Also, in the page \pageref{fig:plot} is the same example.
\begin{wrapfigure}{r}{0.25\textwidth} % this figure will be at the right, and wrap the text around a figure. it will use wrapfig package.
\centering
\includegraphics[width=0.25\textwidth]{./2018-06-26_222331}
\caption{wrap\_one}
% \label{fig:wrap_one}
\end{wrapfigure}
There are several ways to plot a function of two variables,
depending on the information you are interested in. For
instance, if you want to see the mesh of a function so it
easier to see the derivative you can use a plot like the
one on the left.SSS
\begin{wrapfigure}{l}{0.25\textwidth} % This is the width of figure box. Notice that the length is relative to the text width.
\centering % the image will be centred by using its container as reference, instead of the whole text.
\includegraphics[width=0.25\textwidth]{./2018-06-26_222331}
\caption{wrap\_two}
\end{wrapfigure}
On the other side, if you are only interested on
certain values you can use the contour plot, you
can use the contour plot, you can use the contour
plot, you can use the contour plot, you can use
the contour plot, you can use the contour plot,
you can use the contour plot, like the one on the left.
On the other side, if you are only interested on
certain values you can use the contour plot, you
can use the contour plot, you can use the contour
plot, you can use the contour plot, you can use the
contour plot, you can use the contour plot,
you can use the contour plot,
like the one on the left.
On the other side, if you are only interested on
certain values you can use the contour plot, you
can use the contour plot, you can use the contour
plot, you can use the contour plot, you can use the
contour plot, you can use the contour plot,
you can use the contour plot,
like the one on the left.
\begin{comment}
% Generating high-res and low-res images
\DeclareGraphicsExtensions{.png,.pdf}
\DeclareGraphicsExtensions{.pdf,.png}
\begin{comment}
\listoffigures
\textbf{Unordered lists}
\begin{comment}
The default label scheme for itemized lists is:
Level 1 is \textbullet (•),
Level 2 is \textendash (–) ,
Level 3 is \textasteriskcentered (*)
Level 4 is \textperiodcentered (·).
\end{comment}
\begin{itemize}
\item First Level
\begin{itemize}
\item Second Level
\begin{itemize}
\item Third Level
\begin{itemize}
\item Fourth Level
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\begin{itemize}
\item Default item label for entry one
\item Default item label for entry two
\item[$\square$] Custom item label for entry three
\item[$\blacksquare$] Custom item label for entry three
\end{itemize}
\renewcommand{\labelitemi}{$\blacksquare$} % used info in amssymb package, and the renewcommand will effect the rest of document format.
\renewcommand{\labelitemii}{$\square$}
\begin{itemize}
\item First Level
\begin{itemize}
\item Second Level
\begin{itemize}
\item Third Level
\begin{itemize}
\item Fourth Level
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\textbf{Nested Lists}
\begin{enumerate}
\item The labels consists of sequential numbers.
\begin{itemize}
\item The individual entries are indicated with a black dot, a so-called bullet.
\item The text in the entries may be of any length.
\end{itemize}
\item The numbers starts at 1 with every call to the enumerate environment.
\end{enumerate}
\textbf{Ordered lists}
\begin{enumerate}
\item First level item
\item First level item
\begin{enumerate}
\item Second level item
\item Second level item
\begin{enumerate}
\item Third level item
\item Third level item
\begin{enumerate}
\item Fourth level item
\item Fourth level item
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\begin{comment}
The default numbering scheme is:
Arabic number (1, 2, 3, ...) for Level 1
Lowercase letter (a, b, c, ...) for Level 2
Lowercase Roman numeral (i, ii, iii, ...) for Level 3
Uppercase letter (A, B, C, ...) for Level 4.
Code Description
\alph Lowercase letter (a, b, c, ...)
\Alph Uppercase letter (A, B, C, ...)
\arabic Arabic number (1, 2, 3, ...)
\roman Lowercase Roman numeral (i, ii, iii, ...)
\Roman Uppercase Roman numeral (I, II, III, ...)
\end{comment}
\renewcommand{\labelenumii}{\Roman{enumii}} % The command \renewcommand{\labelenumii}{\Roman{enumii}} changes the second level to upper case Roman numeral.
\begin{enumerate}
\item First level item
\item First level item
\begin{enumerate}
\setcounter{enumii}{4} % To change the start number or letter you must use the \setcounter command.
\item Second level item
\item Second level item
\begin{enumerate}
\item Third level item
\item Third level item
\begin{enumerate}
\item Fourth level item
\item Fourth level item
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\begin{comment}
It is possible to change the labels of any level, replace labelenumii for one of the listed below.
\theenumi for Level 1
\theenumii for Level 2
\theenumiii for Level 3
\theenumiv for Level 4
\end{comment}
\textbf{Adding math to LaTeX}
\begin{itemize}
% To put your equations in inline mode use one of these delimiters: \( ... \), $ ... $ or \begin{math} ... \end{math}. They all work and the choice is a matter of taste.
\item \textbf{Inline model:}
In physics, the mass-energy equivalence is stated by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.
% The displayed mode has two versions: numbered and unnumbered.
% To print your equations in display mode use one of these delimiters: \[ ... \], $$ ... $$,\begin{displaymath} ...\end{displaymath} or \begin{equation} ... \end{equation}
\item \textbf{Display model:}
The mass-energy equivalence is described by the famous equation
$$E=mc^2$$
discovered in 1905 by Albert Einstein. In natural units ($c = 1$), the formula expresses the identity
% Important Note: equation* environment is provided by an external package.
\begin{equation}
E=m
\end{equation}
\end{itemize}
Subscripts in math mode are written as $a_b$ and superscripts are written as $a^b$.
These can be combined an nested to write expressions such as
$$T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} =
T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q})$$
We write integrals using $\int$ and fractions using $\frac{a}{b}$. Limits are placed on integrals using superscripts and subscripts:
$$\int_0^1 \frac{1}{e^x} = \frac{e-1}{e}$$
Lower case Greek letters are written as $\omega$ $\delta$ etc. while upper case Greek letters are written as $\Omega$ $\Delta$.
Mathematical operators are prefixed with a backslash as $\sin(\beta)$, $\cos(\alpha)$, $\log(x)$ etc.
\textbf{Basic Formatting}
\textbf{\textit{Abstracts}}
\begin{abstract}
This is a simple paragraph at the beginning of the document. A brief introduction about the main subject.
\end{abstract}
Now that we have written our abstract, we can begin writing our first paragraph.
% When writing the contents of your document, if you need to start a new paragraph you must hit the "Enter" key twice (to insert a double blank line). Notice that LaTeX automatically indents paragraphs.
This line will start a second Paragraph.
%To start a new line without actually starting a new paragraph insert a break line point, this can be done by \\ or \newline command.
\\ This will start a new line.
\newline This will start a another line.
% Commands to organize a document vary depending on the document type, the simplest form of organization is the sectioning, available in all formats.
% \chapter{Chapter} % chapter syntax not working in article environment, \part and \chapter are only available in report and book document classes.
\section{First Section}
This is the first section. % by default, LATEX does not indent the first paragraph of a section.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdiet mi necante... \par
\setlength{\parindent}{10ex} % setting the indent of a paragraph.
This is the text in second paragraph. This is the text in second
paragraph. This is the text in second paragraph.
\noindent % the next paragraph is not indented.
This is the text in third paragraph. This is the text in third
paragraph. This is the text in third paragraph.
\subsection{First Subsection}
Praesent imperdietmi nec ante. Donec ullamcorper, felis non sodales...
\subsection*{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisissem.
% we could multiple comments in latex as follow
\begin{comment}
The basic levels of depth are listed below:
-1 \part{part}
0 \chapter{chapter}
1 \section{section}
2 \subsection{subsection}
3 \subsubsection{subsubsection}
4 \paragraph{paragraph}
5 \subparagraph{subparagraph}
\end{comment}
\textbf{Creating a simple table in LaTeX}
\begin{table}
\begin{center}
\begin{tabular}{| c | c | c |} % specify the parameter of tabular environment. declares that three columns, separated by a vertical line, also can use {| l | l | l |} or {| r | r | r |}
% we can add borders using the horizontal line command \hline and the vertical line parameter |.
\hline % horizontal line
cell1 & cell2 & cell3 \\ % do not forget to add \\ characters.
\hline
cell4 & cell5 & cell6 \\ % Each & is a cell separator and the double-backslash \\ sets the end of this row.
\hline\hline
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{center}
\end{table}
Table \ref{table:data} is an example of referenced \LaTeX{} elements, and it is in page \pageref{table:data}.
\begin{table}
\begin{center}
\begin{tabular}{||c c | c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
\hline
2 & 7 & 78 & 5415 \\
\hline
3 & 545 & 778 & 7507 \\
\hline
4 & 545 & 18744 & 7560 \\
\hline
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}
\caption{Table to test captions and labels} % description of the table.
\label{table:data} % the unique lable of the table.
\end{center}
\end{table}
\begin{center}
\begin{tabular}{ | m{5em} | m{1cm}| m{1cm} | }
\hline
cell1 dummy text dummy text dummy text& cell2 & cell3 \\
\hline
cell1 dummy text dummy text dummy text & cell5 & cell6 \\
\hline
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{center}
\begin{tabu} to 0.8\textwidth { | X[l] | X[c] | X[r] | }
\hline
item 11 & item 12 & item 13 \\
\hline
item 21 & item 22 & item 23 \\
\hline
\end{tabu}
\date{\today}
\end{document}