## Introduction to LaTeX

Category : Uncategorized

# Introduction to LaTeX

We use LaTeX for our documents. It is scientific, it is free, and it is system independent.
To contribute to the free scientific learning, we provide LaTeX resources in this page.

### LaTeX Editor

A simple notepad works as a LaTeX editor. We use TextWrangler (Mac) as our editor. It is free!

### LaTeX Compiler

LaTeX documents need to be compiled (converted) into PDF files. So, you need a compiler.

We use MikTeX as our computer installed LaTeX compiler.
You need to donwload and install this software on your computer. It is free!

### LaTeX template file

In this sections, we provide details of writing with LaTex.
The following code snippets make up a LaTeX template file.

#### 1) Preliminaries:

LaTeX works in fields. A field can be a command, definition, special character, section, paragraph, font definition etc.

 \section{Introduction} \subsection{Preliminaries} \subsubsection{This is important}

In this example, the field, section, defines a section. The field content is included within the { and }.
In the text, this command would define a section: Introduction.

 Parts of this {\bf text will be bold}.
In this example, the field, bf, defines a bold face. The content to be bold faced is included within the { and }.

 There is 10\% return. There is \$10 return.  The fields start with a \. These also define special characters. Since % sign defines comments in LaTeX and they do not get compiled, if we need to include % sign and not a comment, then we need to include \ in front of the % sign. The$ and & signs are also special characters in LaTeX. $sign defines in-line equation, begin and end. Thus, if we need the$ or & signs then we would need to include \ in front of them.

 \begin{center} This text will be centered. \end{center}
In some instances, fields are defined with \begin and \end. The actual field definition would go in between { and }.
The content of the field would be between the \begin and \end.

#### 2) Preparation:

Copy-paste the following snippets into a notepad file.
Save it with .tex file extension (i.e. myfile.tex)
Double-click on your newly created LaTeX file (i.e. myfile.tex)
It will open in MikTeX.
Choose pdfLaTeX+MakeIndex+BibTex (that is what I choose).
TypeSet

#### 3) Declare what your document class is.

 \documentclass {article}
This can be an “article”, “book”, “beamer” etc.
There are many more. I only used these three. The “article” and “book” are obvious.
“beamer” is for presentations.

 \usepackage{pdfpages,graphicx,epsfig,stata,shadow,natbib,color,amssymb,amsthm,amsmath,longtable,lscape} \usepackage[stable]{footmisc} \usepackage{hyperref} % hyperref must be the last package

For instance, natbib helps you define bibliography. color helps you include color schemes to all your styles.
pdfpages allows you to include pages from pdf documents into your LaTeX document.
There are many packages. CTAN is contains descriptions of many packages (if not all).

You can also have new definitions in your preamble.
 \definecolor{midnightblue}{RGB}{25,25,112} \definecolor{navyblue}{RGB}{0,0,128} \definecolor{royalblue}{RGB}{0,34,102}

Options for the packages goto preamble as well.
 \hypersetup{ bookmarks=true, % show bookmarks bar? unicode=false, % non-Latin characters in Acrobat's bookmarks pdftoolbar=true, % show Acrobat's toolbar? pdfmenubar=true, % show Acrobat's menu? pdffitwindow=false, % window fit to page when opened pdfstartview={FitH}, % fits the page width to the window pdftitle={Finance-PoliSci}, % title pdfauthor={Dicle & Dicle}, % author pdfsubject={Learning LaTeX}, % subject of the document pdfcreator={Dicle & Dicle}, % creator of the document pdfproducer={Dicle & Dicle}, % producer of the document pdfkeywords={keyword1} {keyword2}, % list of keywords pdfnewwindow=true, % links in new window colorlinks=true, % false: boxed links; true: colored links linkcolor=royalblue,% color of internal links citecolor=midnightblue, % color of links to bibliography filecolor=black, % color of file links urlcolor=blue % color of external links }

LaTeX documents hyphenate. Sometimes, word get cut off in undesirable places. You can include hyphenation rules in your preample.
here.
 \hyphenation{book-let note-pad}

You can define new commands. These can also be used like variable definitions, shorthands etc.
 \newcommand{\journal}{Journal of Free Scientific Advancement}

Entire contents of the preamble can be saved in a TeX file. Then, this TeX file can be included into your main LaTeX document.
This would make your main LaTeX document tidy. Note tough, you either include your preamble as an outside file or type them as they are to your LaTeX document.
The preamble.tex file includes all we wrote above for the preamble section.
 \input{preamble.tex}

#### 5) Define the start of your LaTeX document content.

From this point on, your actual text starts.
 \begin{document}

#### 6) Cover page

 \title{This is my first \LaTeX\ document} \author{ Dicle \& Dicle\thanks{Special thanks to our cats.} \\ Finance \& Political Science \\ financepolisci.com, WWW 010101} \maketitle
Notice the double back slashes (\\). These mean line breaks.

 \newpage \tableofcontents \newpage \listoffigures \newpage \listoftables
Notice the \newpage, which starts a new page.

#### 8) Chapters and sections

 \chapter{1} \section{Introduction} \subsection{Introduction - Past} \subsection{Introduction - Future} \section*{Literature review}
The chapter field will only work if your document style is report.
Your sections will have automatic numbering. However, the literature review section will not have a number
because we put a * in it. This will also exclude this section from the table of contents.

#### 9) Citations

 In this study, we are initially replicating the \citet{dicle2010}. <code></code>The evidence is provided in favor of cats making houses homes.'' \citep{dicle2010}
Before we continue, notice the (the character to the left of 1 on your keyboard) and ” (single quote, twice). These are the double quotes for the LaTeX.
LaTeX will not see “.
Citations and references are one of the reasons we use LaTeX.
While writing your text, use \citet{} for in-line citations and \citep{} for citations within paranthesis.
At the end of your document, include the following where you want your list of references to appear.

 \bibliographystyle{plainnat} \bibliography{bibliography.bib}
The list of all citations you included in your text will be prepared for you.
The bibliography style can be changed as per the journal style requirements.
Using this method, you will never have citations without references or vice-versa.
We will explain how to prepare bibliography (bibliography.bib) files later.

#### 10) Define the end of your LaTeX document content.

Your LaTeX document content ends here.
 \end{document}