Date post: | 07-Apr-2018 |
Category: |
Documents |
Upload: | weijie-chen |
View: | 234 times |
Download: | 0 times |
of 20
8/6/2019 Quite Short LaTeX Introduction
1/20
Quite Short LATEX Introduction
Weijie Chen
Department of Economics
University of Helsinki
6 July, 2011
Contents
1 Buckle Your Seatbelt 3
2 Start! 7
3 Put It Nicely 9
3.1 Cross reference . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Footnote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3 Emphasize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.5 Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.6 Loading a picture . . . . . . . . . . . . . . . . . . . . . . . . . 113.7 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Queen of Science 12
4.1 Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.2 Super- and Subscript . . . . . . . . . . . . . . . . . . . . . . . 134.3 Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Beamer 16
6 Miscellaneous 18
6.1 Your Command . . . . . . . . . . . . . . . . . . . . . . . . . . 186.2 Change Style . . . . . . . . . . . . . . . . . . . . . . . . . . . 186.3 Some marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196.4 Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196.5 Umlaut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
If you have any questions or comments, send email to [email protected]
1
8/6/2019 Quite Short LaTeX Introduction
2/20
List of Figures
1 TEXnicCenter interface . . . . . . . . . . . . . . . . . . . . . . 42 LyX interface . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 TEXmaker interface . . . . . . . . . . . . . . . . . . . . . . . . 54 Lake Louise in Canada . . . . . . . . . . . . . . . . . . . . . . 115 Reserved picture . . . . . . . . . . . . . . . . . . . . . . . . . 126 Beamer Title Page . . . . . . . . . . . . . . . . . . . . . . . . 17
2
8/6/2019 Quite Short LaTeX Introduction
3/20
Abstract
This article is used for helping you quickly master some essentialLATEX skills, especially used for writing your class exercise, final paperor graduation thesis. LATEX can be very confusing for beginners, sinceit is not WYSIWYG1 at all. In the very beginning when you learnLATEX, you desperately watch bunches of LATEX source codes on thecomputer screen which distracts you away from your initial intention,consuming most of your energy on handling with codes rather thanyour thought. I undertand, I had been through this before. Thus Iwrite this article to extract all essential stuff which might help youlearn as quickly as possible, and of most importance, at lowest pain.Hence excuse my informal languages in this article, I have no intentionto make this article read like an academic paper which merely brings
you more pain.
1 Buckle Your Seatbelt
For those people who want to pursue an academic career, LATEX is absolutenecessity. Dont anticipate that you could submit a Ph.D. dissertation writ-ten by MS word. In a word, unprofessional. When you were in classroom,watching teacher clicking folders in his/her USB, didnt you notice that mostof your teachers do not use Powerpoint to show you his/her course slides?He/she usually opens a pdf file, then it becomes course slides, and it looksrather neat and nice-looking. I can assure you, these slides were made by
LATEX. You must have following experience when dealing with MS word,although it is considerably straighforward, it seems always inconsistent ineverything, such as fonts change, line space differs, picture unproportionallyscales, messes of footnotes, chaos of bibliography. . . Well, I might have ex-agerated a little bit, you might also turn fastidious with MS Office after youget to know LATEX quite well. You even get a basic sense of how LATEX out-put look like from reading my article, since my article is compile by LATEX,I guess you will notice lots of differences from MS Word.
LATEX is not a word processor programme, it is a typesetting system.From my perspective, it can be regarded as script programming2. But thissystem is embedded into some window interface programme into which you
can type your articles. I recommend some programmes here, once you getfamiliar with one, you can try others, but dont start with several together.
1. TEXnicCenterThis is my favourite, most of time I use this IDE3 to typeset my article.
1 What you see is what you get. Microsoft Word and Powerpoint belongs to this
catagory.2 If you do not know this terminolgy from computer programming, dont bother.3 Integrated development environment, again, dont bother.
3
8/6/2019 Quite Short LaTeX Introduction
4/20
interface.png
Figure 1: TEXnicCenter interface
2. LYX LYX is designed to have word processor interface, which makesit rather easy to get hands on, very suitable for absolute beginners.But its output layout setting is different from standard thesis writing
setting, and if you dont know how to reset, it might be a problem.Lots of universities privided on their computers.
3. TEXmakerA rather popular IDE among LATEX users. Simple and neat interface,wont make you feel lost.
They are all free to download from their website, just go to their websiteand browse the instruction, it wont take more than 10 minutes. Beforeinstallation of these programme, you should install MiKTEX first, which isthe core of everything else, packages gather in it.
Now take a look at this,
\sum_{i=1}^k=\boldsymbol{X}_tu_t
This is how we compile mathematics in LATEX, rather scary? Dontworry, you will get used to it. The output of this line will be
ki=1
= Xtut
Here is more, you will get the basic sense how we work in LATEX environment,
4
8/6/2019 Quite Short LaTeX Introduction
5/20
interface.png
Figure 2: LyX interface
interface.png
Figure 3: TEXmaker interface
5
8/6/2019 Quite Short LaTeX Introduction
6/20
\begin{equation*}
\begin{bmatrix}x_{11} & x_{12} & \cdots & x_{1k}\\
x_{21} & x_{22} & \cdots & x_{2k}\\
\vdots & \vdots & \ddots & \vdots\\
x_{n1} & x_{n2} & \cdots & x_{n3}
\end{bmatrix}
\begin{equation*}
I know you get a headache, but here is the output, quite nice, right?
x11 x12 x1kx21 x22 x2k
......
. . . ...xn1 xn2 xn3
So I said it is very confusing in the very beginning, it seems you have toremember endless meanless codes before you even start writing your thesis.But this is the right path to walk, you work through some simple exampleand develop your own style. The more you get in touch with LATEX, themore you will know its temper.
6
8/6/2019 Quite Short LaTeX Introduction
7/20
2 Start!
Now I want to you to try set up your first LATEX file, just follow all linesbelow, put them into your LATEX typesetting programme.
\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsthm,amsmath,amsfonts}
\usepackage{mathrsfs,syntonly,graphicx,color,hyperref}
%\syntaxonly
\title{My first \{LaTeX} file}
\author{Your name here!}
\date{6 July, 2011}
\begin{document}
\maketitle
\section{My first section}
This is awesome! Haha!
\section{My second section}
I am hungry\ldots
\end{document}
Well, you have successfully make your first step, now let me brieflyexplain what we did in those lines. There is a name for area between
\documentclass{article} and \begin{document}, it is called preamble.The first line \documentclass[11pt,a4paper]{article} , indicates whatkind of project you are working on, article, book, or slides, etc. And through-out all file, font size will be set at 11 points, and A4 paper size.
Second and third line requires LATEX distribution to load various packageto help you complete your project. Because initially LATEX does not have somuch function, or we could say it is rather limited. So different institutesprovides their package to increase LATEXs flexibility. American Mathemat-ical Sociaty provides several packages, which makes LATEX almost can dealwith any kinds of math notation you can imagine. I guess, you can guessfrom the names of the package to some extent. syntonly is used as checking
syntax correction, if you load this package, and you have \syntaxonly onnext line, your LATEX platform does not produce output, such as .pdf or .dvi,it only check the syntax, which will save some time when you are runningsome huge projects. graphicx is a must if you need to load picture intoyour article. color package change the fonts colour as I did here.hyperrefwill package is very useful, it makes all your reference in pdf file into hyper-link, which could zap you to the point in the article you refer to by justclicking it, try this 1, go to figure 1. After all these explanation, I wouldrather suggest you no matter what you write, just load them all, put them
7
8/6/2019 Quite Short LaTeX Introduction
8/20
into your favourite template, since computer nowadays is so fast, loading
package time is almost neglectable.Continue, title, author, date is straightforward, needless to explain,
help yourself.
\maketitle
\section{My first section}
This is awesome! Haha!
\section{My second section}
I am hungry\ldots
\end{document}
Note that this is the body of article, between \begin{document} and
\end{document}. is must, unless you dont want a title of your article.Beside title, you might need contents, you also can use \tableofcontents,\listoffigures and \listoftables, just put them there, you will seethe effect later on. \section{} is the first structrual level of an article,then \subsection{} and \subsubsection{}. If you are writing a book,\documentclass{book} , \chapter{} will be the first structrual level.
Now you have the basics of LATEX, just go write some basic stuff!
8
8/6/2019 Quite Short LaTeX Introduction
9/20
3 Put It Nicely
I present all most frequently used function here, I presume that almost everythesis writing would need these basic skills.
3.1 Cross reference
When you want to refer to a sentence or a word, just put \label{} at theend of that sentence or word, write anything you want in that bracket sobe the unique label. Next, you set up and hyperlink by using \ref{}, thecontent in the curly braces should be exactly the same as in \label{}, whichyou intend to refer to. If you are referring to an equation, you should use\eqref{}, referring a page, you should use \pageref{}.
3.2 Footnote
This is an article teaching you\\
how to use {\LaTeX}.\footnote{ See? This is footnote.}
Follow the example above, \footnote{}, is the command you want towrite footnote. The same, write them in curly braces.
3.3 Emphasize
Let me put this straight, in a printed book or a thesis you do not em-phasize a word by using boldfonts. You do this by either emphasizethem or emphasize them. The command accordingly are, \emph{} and\underline{}. But underline is used very rarely and old-fashioned, I sug-gest you use former one.
3.4 Environment
This is environment,
\begin{document}
\begin{abstract}
\end{abstract}
\begin{equation}
\begin{bmatrix}
\end{bmatrix}
\end{equation}
\end{document}
9
8/6/2019 Quite Short LaTeX Introduction
10/20
it always starts with \begin{}. Ends with \end{}. In the curly braces,you write what environment you intend to get into. Within
\begin{document}
...
\end{document}
is the main body as I said before. Inside abstract environment,
\begin{abstract}
...
\end{abstract}
you write you abstract. Equation environment,
\begin{equation}
...
\end{equation}
brings you into math mode, where you start a seperate line to write yourmathematics. We will come back to \begin{bmatrix}...\end{bmatrix}later.
3.5 Enumeration
Just follow commands below, you will get it, it is easy.
\begin{enumerate}
\item Microeconomics
\item Macroeconimics
\item Econometrics
\end{enumerate}
Last one is enumerate environment, it marks numbers in front of item,if you do not need numbers, try this
\begin{itemize}
\item Microeconomics
\item Macroeconimics
\item Econometrics
\end{itemize}
10
8/6/2019 Quite Short LaTeX Introduction
11/20
As always, I also put output here for your comparsion,
1. Microeconomics
2. Macroeconimics
3. Econometrics
Microeconimics
Macroeconimics
Econometrics
3.6 Loading a picture
First you should prepare a picture in the same folder as you current com-piling .tex file. Then we use figure environment.
\begin{figure}
\centering
\includegraphics[width=12.5cm]{name of your picture}
\caption{Enter your caption here} \label{fig1}
\end{figure}
\centering is used to put picture in the center, not left or right. Then just put the exact same name of the picture under same folder into thatcurly braces, then enter captions whatever you want. Here I load a picturefrom my computer 4.
Sometimes you know you need to put picture right at some place, butthe problem is you havent drawn yet, you just keep writing, then you might
Lake.jpg
Figure 4: Lake Louise in Canada
11
8/6/2019 Quite Short LaTeX Introduction
12/20
really forget about this, if you thesis writing lasts long enough (which I
hope not!). So you probably should insert an empty box 5 here to reservethe place for images, inorder to remind the truth-not yet.
This is where I reserved my picture!
Figure 5: My reserved place for picture
3.7 Bibliography
Do you ever wonder what is the difference between bibliography and refer-ence? I wondered it too, I even asked my teacher. However opinions varies.
But in LATEX, bibliography is used in book environment, and reference isused mainly in article environment.
\begin{thebibliography}{99}
\bibitem{spanos} Spanos A. (1986):
\emph{Statistical foundations
of econometric modelling.},
first edition,
Cambridge University Press
\end{thebibliography}
Above is the thebibliography environment, dont worry about whether itis called bibliography or reference, LATEX will choose for you. Just followthem, put your own content in curly braces. Note that in \bibitem{dou},dou is a marker, or label, it connects the place you mention the referencesby a hyperlink. You just need to type in a \cite{dou} at the place yourefer.
4 Queen of Science
Yes, Guass said . . . . However, mathematics gives lots of student nightmare,
sometimes is due to wrongly presentation. When you open a book, fullof formulas and hard-reading sub- or superscripts, acompanied by endlessoverwhelming paragraphs. Besides nausea, I cannot imagine other properreactions. If you deny that typesetting also disgust you from reading, justimagine there is novel written on the wall which is 10 metres long, will yoube happy reading it?
In this section, I only teach you how to use these codes, but I do notteach what codes are, it is meaningless for me to reproduce those mathsymbos here, there are great bunch of table made for easy reference. Youcan check other real references, such as The Not So Short Introduction to
12
8/6/2019 Quite Short LaTeX Introduction
13/20
LATEX 2[1]. Remember, this is only scratching the surface of the surface,
but enough is good.
4.1 Equations
If you want to input mathematics within text, you use $...$, if seperatately,use \begin{equation}...\begin{equation} . If we replace equation byequation*, numbers are removed. But sometimes you need to have yourown mark on equations, rather than numbers, you can use \tag{} to changeany mark you like, put any word or number in the curly braces you like. Seebelow
\begin{equation*}
s^2=\frac{1}{n}\sum_{t=1}^n\hat{u}_t\tag{ice_cream}
\end{equation*}.
And result is
s2 =1
n
nt=1
ut. (ice cream)
I tag it as ice cream.There is one situation when you have several equations, impossible to
put them in a single line, you align them by setting a reference point.
\begin{align*}a-c+b-d&=x+y+z\\
&=e+f+g+h+i\\
&=j+k+l+m+n+o+p
\end{align*}
Notice that you put a & in front of the reference point, equations beneathwill follow at that point. Result is
a c + b d = x + y + z
= e + f+ g + h + i
= j + k + l + m + n + o + p
4.2 Super- and Subscript
Easy, ^2 and _2 are super- and subscript respectively. Try these, x^7,x^{abcde}, X^{abc}_{123}, X^{b^a}_{c_d}. Output are below,
x7 xabcde Xabc123 Xba
cd.
Besides, integration, summation and product operators, all can need super-and subscript.
13
8/6/2019 Quite Short LaTeX Introduction
14/20
\begin{equation*}
\int_a^b{\frac{x^2}{\pi}} \,\mathrm{d}x\qquad \prod_{t=1}^n\beta^tE(u_t)
\end{equation*}
Check your result,
b
a
x2
dx
nt=1
tE(ut)
4.3 Matrix
Now I want you to look back 1. Try to figure out how it works, read slowly.I present another kind of matrix notation here,
\begin{equation*}
\begin{pmatrix}
x_{11} & x_{12} & \cdots & x_{1k}\\
x_{21} & x_{22} & \cdots & x_{2k}\\
\vdots & \vdots & \ddots & \vdots\\
x_{n1} & x_{n2} & \cdots & x_{n3}
\end{pmatrix}
\begin{equation*}
Did you notice the difference of our command, here I use\begin{pmatrix}...\end{pmatrix} . It looks like,
x11 x12 x1kx21 x22 x2k
......
. . ....
xn1 xn2 xn3
If you want to write a matrix multiplication, you just write several matricesin a same equation environment.
\begin{equation*}
\begin{bmatrix}
x_{11} & x_{12} & \cdots & x_{1k}\\
x_{21} & x_{22} & \cdots & x_{2k}\\
\vdots & \vdots & \ddots & \vdots\\
x_{n1} & x_{n2} & \cdots & x_{n3}
\end{bmatrix}
\begin{bmatrix}
\beta_1\\
14
8/6/2019 Quite Short LaTeX Introduction
15/20
8/6/2019 Quite Short LaTeX Introduction
16/20
\begin{equation*}
\begin{bmatrix}1 & 8 & 3 & \llap{-}2 & 4\\
0 & \llap{-}1 & \llap{-}2 & 9 & 2\\
0 & 0 & 3 & 1 & 5\\
0 & 0 & 0 & 5 & \llap{-}4\\
0 & 0 & 0 & 0 & 6
\end{bmatrix}
\end{equation*}
And corresponding ouput is:
1 8 3 -2 4
0 -1 -2 9 20 0 3 1 50 0 0 5 -40 0 0 0 6
5 Beamer
One of the most important documentclass is beamer, it is used to creatyou fancy slides, when you are on a presentation of your thesis to yoursuperviser and other defense opponents. The time of Powerpoint is gone. Ibarely see any professors using Powerpoint, since it kind of degenerate the
rigourous level of your presentation. If you need to crush some slides togive a course presentation tomorrow morning, you use Powerpoint to makefast slides, no one will blame you. But be careful, when you present yourstuff among academia, appearance matters as well as contents. Here is onebeamer sample,
\documentclass{beamer}
\mode
\usepackage{amssymb,amsthm,amsmath,}
\usepackage{graphicx,verbatim,textcomp}
\usepackage{amsfonts,mathrsfs,syntonly}\usepackage{color,hyperref}
\usetheme{Frankfurt}
%\usecolortheme{lily}
\title{How to Cook Instant Noodles}
%\subtitle{}
\author{Weijie Chen}
\institute{\scriptsize Department of Economics\\
16
8/6/2019 Quite Short LaTeX Introduction
17/20
noodle.pdfOutline General overview of the project Last 6 months Next 6 months
How to Cook and Eat Instant Noodles
Weijie Chen
Universiteit van Amsterdam
11 July, 2010
Weijie Chen How to Cook and Eat Instant Noodles
Figure 6: Beamer Title Page
\vspace{.10cm}Universiteit van Amsterdam}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section*{Outline}
\begin{frame}
\tableofcontents
\end{frame}
\section{What is Instant Noodle}
\subsection{Ingredients}
Instant noole is made of \cdots
\end{document}
17
8/6/2019 Quite Short LaTeX Introduction
18/20
\usetheme{Frankfurt} is a theme package named Frankfurt, almost
all theme package names are named after a city or town, for more detailedinformation you should check The Beamer class User Guide [2]. However, asyou can see, it is no significant difference than compiling articles or books,you just need to use \begin{frame}...\end{frame} to make a slide, anefill in it with your own content, such mathematics, pictures, etc. However ifyou need far more function than this plain sample, you need to study TheBeamer class User Guide [2], it is a rather long manual.
6 Miscellaneous
Rest of things I put here, it might be more interesting to explore LATEX by
yourself.
6.1 Your Command
Working on LATEX can be very time consuming especially you have hugebunches of math symbol to deal with. If you repeatedly use some com-mands, and they are combination of several, you might consider to use anew command to replace them, not really replace, just a self-made con-densed version. Say you have to type in X1 thousands of times in yourfile, it is rather boring. Now we set a new command for it. Put this\newcommand{\bx}{\boldsymbol{\hat{X}}_{\!{1}}} at your preamble.
Then try this
\begin{equation*}
\bx
\end{equation*}
See? Quite convenient.
6.2 Change Style
Take look at this first,
n
i=1xi
n
i=1yi
n
i=1yi
n
i=1xiyi
As you have already notice that summation operation does not display as itsusual form, because they are in a matrix. If summation, product, integraloperation will be displayed like this if you put them into matrix or fraction.You might want to use \displaystyle{} to turn it back. Just put the
18
8/6/2019 Quite Short LaTeX Introduction
19/20
summation into its curly braces,
ni=1
xi
ni=1
yi
ni=1
yi
ni=1
xiyi
you have seem the modified output, it looks not so intensive as the first one,so I suggest you be careful when use some command to override LATEXspreset command.
6.3 Some marks
Did you ever use yet? LaTeX usually does not display like, and it hasdifferent input than it looks like, if you want to put quotation mark such as
Know thyself.
Note that the first mark, is , is the button on the left of number 1 onan American keyboard layout.
6.4 Spacing
From an aesthetic view, mathematics should present in a gentle way, not anysurpassingly spacing, not any exceedingly constringing. Put mathematics ina readable, or attractive manner is an art! The appearance of an article isshould be decorated just like a room, put things in the right place, it shines.Let me show you two examples,
b
a
sin
2du
f(x,y,z)dxdydz
do you feel any uncomfortable when wathcing them? Spacing! The codesare follows,
\begin{equation*}
\int_a^b\sin{\frac{\pi}{2}}\mathrm{d}u
\qquad \int\int\int{f(x)}\mathrm{d}x{d}y{d}z
\end{equation*}
When you are dealing with micro-distance between symbols within anexpression, you use \! to shrink, and \, to expand space. Now it becomes,
b
a
sin
2du
f(x,y,z) dxdy dz.
Here is the codes,
19
8/6/2019 Quite Short LaTeX Introduction
20/20
\begin{equation*}
\int_a^b\sin{\frac{\pi}{2}}\,\mathrm{d}u\qquad \int\!\!\int\!\!\int{f(x,y,z)}
\,\mathrm{d}x\,\mathrm{d}y\,\mathrm{d}z.
\end{equation*}
6.5 Umlaut
You probably would write your thesis in a languge other than English, maybeGerman, Swedish, Finnish. You might need to use letters such as a, o, u.In German, they are called umlaute. Here is a small table,
a o u a c o\"a \"o \"u \aa \^c \c o
Table 1: Most frequent acute symbols
The End.
References
[1] Oetiker T.(2010): The Not So Short Introduction to LATEX 2, version4.31
[2] Wright J. and Miletic V. (2010): The Beamer Class User Guide
20