latex tutorial

72
LaTeX Tutorial 2015.01.28 ݣ

Upload: tai-lun-tseng

Post on 07-Jan-2017

364 views

Category:

Education


3 download

TRANSCRIPT

Page 1: LaTeX Tutorial

LaTeX Tutorial2015.01.28

Page 2: LaTeX Tutorial

Agenda•

• LaTeX

• Hello LaTeX!

• Bibliography

• Build

• Writing Tips

Page 3: LaTeX Tutorial

LaTeX

• LaTeX TeX Leslie Lamport

• Leslie Lamport: LaTeX, Paxos algorithm, 2013 Turing award

• TeX Knuth

Page 4: LaTeX Tutorial

LaTeX •

• Word + OneNote LaTeX

• Knuth The Art of Computer Programming TeX

Page 5: LaTeX Tutorial

LaTeX • Beamer

• Pandoc

• musixtex

• circuitkz

Page 6: LaTeX Tutorial

• LaTeX

• /ˈleɪtɛk/ /ˈlɑːtɛk/

• X k

Page 7: LaTeX Tutorial

LaTeX • Overleaf

• https://www.overleaf.com

• writelatex WYSIWYG

• build ...

• StackExchange TeX

• http://tex.stackexchange.com

• BJ4

Page 8: LaTeX Tutorial

LaTeX • LaTeX Wikibook

• http://en.wikibooks.org/wiki/LaTeX

• (?)

• CTAN

• http://www.ctan.org

• TeX package

• API Reference

Page 9: LaTeX Tutorial

Installation• http://en.wikibooks.org/wiki/LaTeX/Installation

• Linux: TeX Live package

• distribution 200 - 300 MB

• Windows: MiKTeX 160 MB

• Mac: MacTeX 2.4 GB

Page 10: LaTeX Tutorial

Hello LaTeX!\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

Page 11: LaTeX Tutorial
Page 12: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

Page 13: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

• \documentclass

• a4paper: A4

• 12pt: 12

• report:

Page 14: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

• \begin \end

• document

Page 15: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

• • \LaTeX: LaTeX command

Page 16: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

• \emph: emphasis

• \textbf:

• \rq: right quote

• .tex

Page 17: LaTeX Tutorial

\documentclass[a4paper, 12pt]{report}

\begin{document}

Hello, \LaTeX{}!

\emph{Welcome} to this \textbf{world}!

Ito\rq{}s formula:

$$ dX_t = \mu_tdt + \sigma_tdB_t $$

\end{document}

• $ TeX

• $ $

Page 18: LaTeX Tutorial

• .tex

• indent

• # $ % ˆ & _ { } ̃ \

• Tab

• %

Page 19: LaTeX Tutorial

LaTeX Group• { } group

• {

\color{red}

This line will be red.

}

This line will not.

Page 20: LaTeX Tutorial

LaTeX Command• command

• function

• { } argument

• [ ] optional option

Page 21: LaTeX Tutorial

LaTeX Environment

• \begin{name} \end environment

• Environment command environment

Page 22: LaTeX Tutorial

Input TeX Files• include

• \input{another.tex}

• another.tex \input

• .tex \input

Page 23: LaTeX Tutorial

• Global structure

• Document class

• Package

• Chapter, section, subsection

Page 24: LaTeX Tutorial

Global Structure\documentclass{…}

\usepackage{…}

% settings

\begin{document}

% content…

\end{document}

• document class

• document

Page 25: LaTeX Tutorial

Document Class

article Journal short report etc.

report chapter

book book

IEEEtran IEEE Transaction format

Page 26: LaTeX Tutorial

Document Class• options

10pt, 11pt, 12pt 10pt 12pt

a4paper, letterpaper

onecolumn, twocolumn column twocolumn

twoside, oneside book twoside article & report oneside

Page 27: LaTeX Tutorial

Package• \usepackage{…} package

• \usepackage{verbatim}

• cite citation

• graphicx

• tabularx

• listings

Page 28: LaTeX Tutorial

• LaTeX

• \chapter book report

• \section

• \subsection

• \subsubsection

Page 29: LaTeX Tutorial

...• List (ordered &

unordered)

• Font

• Source code

• Table

• Table of Contents

• Citation and Footnote

• Figure

• Reference

Page 30: LaTeX Tutorial

List (unordered)

\begin{itemize}

\item The first item

\item The second

\item The third

\end{itemize}

• The first item

• The second

• The third

Page 31: LaTeX Tutorial

List (ordered)

\begin{enumerate}

\item The first item

\item The second

\item The third

\end{enumerate}

1. The first item

2. The second

3. The third

Page 32: LaTeX Tutorial

\begin{enumerate}

\item The first item

\begin{itemize}

\item 1 of the first

\item 2 of the first

\end{itemize}

\item The second

\end{enumerate}

1. The first item

• 1 of the first

• 2 of the first

2. The second

Page 33: LaTeX Tutorial

Font

• \textbf{…}

• \emph{…}, \italic{…}

• monospace \texttt{…}

Page 34: LaTeX Tutorial

• listings

• \usepackage{listings}

• lstlistings

\begin{lstlistings}[breakline] int my_count = 0; println(“hello world!”); \end{lstlistings}

Page 35: LaTeX Tutorial

• syntax highlight

• document

\lstset{ language=C, numbers=none,

tabsize=2, basicstyle=\ttfamily\small, breakatwhitespace=true }

Page 36: LaTeX Tutorial

• LaTeX

• PPT

Page 37: LaTeX Tutorial

\begin{tabular}{ l l l }

1 & 2 & 3 \\

4 & 5 & 6 \\

7 & 8 & 9 \\

\end{tabular}

1 2 3

4 5 6

7 8 9

Page 38: LaTeX Tutorial

\begin{tabular}{ | c | c | c | }

\hline

1 & 2 & 3 \\

\hline

4 & 5 & 6 \\

\hline

7 & 8 & 9 \\

\hline

\end{tabular}

1 2 3

4 5 6

7 8 9

Page 39: LaTeX Tutorial

Column c

l

r

p{12cm}

| column

|| column

Page 40: LaTeX Tutorial

• \tableofcontents

• book: chapter, section, subsection

• report: section, subsection, subsubsection

Page 41: LaTeX Tutorial

Citation

• \usepackage{cite}

• \cite{bib_key}

• bib_key bibliography key

Page 42: LaTeX Tutorial

Citation

Those techniques are usually used in a client-server scenario where the program is partitioned into tasks and some tasks are offloaded to the server from clients~\cite{MCCSurvey, Chun2011, hung2014mobilefbp}.

Following the emerging HTML5 and JavaScript technologies, web apps are enhanced with increased capabilities that are more specific for mobile contexts \cite{WEBAPP}.

Page 43: LaTeX Tutorial

Footnote• citation bibliography

• footnote

• \footnote{put footnote texts here}

• \footnotemark \footnotetext

Page 44: LaTeX Tutorial

Footnote Web applications are the most widely-adopted cross-platform solution for mobile devices, \footnote{This work was in part supported by MOST under 102-2221-E-002-087-MY3 and by III under 104-EC-17-A-24-0691}

Page 45: LaTeX Tutorial

Footnote

\section[Introduction]{Introduction\footnotemark} \footnotetext{This work was in part supported by MOST under 102-2221-E-002-087-MY3 and by III under 104-EC-17-A-24-0691}

Page 46: LaTeX Tutorial

• \usepackage{graphicx}

• \includegraphics[...]{file_path}

• file_path

• .jpg, .png, .pdf

• .tex \input \input

Page 47: LaTeX Tutorial

• \includegraphics[width=1.0\columnwidth]{…}

• column

• 1.0 .8

• \textwidth twocolumn

Page 48: LaTeX Tutorial

optional ...

• width=xx height=xx

• keepaspectratio

• width height

Page 49: LaTeX Tutorial

Figure

• Figure graphic graphictable

• \begin{figure} \end{figure}

Page 50: LaTeX Tutorial

Figure: graphic\begin{figure}[htb!]

\begin{centering}

\includegraphics[width=1.0\columnwidth]{figures/usecase-webcam}

\caption{A distributed webcams example}

\label{fig:usecase-webcam}

\end{centering}

\end{figure}

figure

Page 51: LaTeX Tutorial
Page 52: LaTeX Tutorial

Figure: table\begin{figure}[htb!] \begin{centering} \begin{tabular} % table content... \end{tabular} \caption{A distributed webcams example} \label{fig:usecase-webcam} \end{centering} \end{figure}

Page 53: LaTeX Tutorial

Figure • Figure float flow • \begin{figure}[htb!] • placement specifier figure

• h: here source code • t: top • b: bottom • !: LaTeX

• LaTeX •

Page 54: LaTeX Tutorial

Figure Graphic

• figure

\begin{figure}[htb!] \includegraphics[width=1.0\columnwidth]{file1} \caption{Caption 1} \label{fig:file1} \includegraphics[width=1.0\columnwidth]{file2} \caption{Caption 2} \label{fig:file2} \end{figure}

Page 55: LaTeX Tutorial

Label• \label{label_name}

• \chapter \section figure

• label_name

• \label{fig:system_architecture}

• \label{sec:introduction}

Page 56: LaTeX Tutorial

Reference• ref

The high-level overview of Migratom.js is illustrated in Figure~\ref{fig:Architecture}.

• FigureChapter Table !!

Page 57: LaTeX Tutorial

Bibliography• LaTeX bib

• BibTeX

• .bib key-value pair citation

• \cite{key} Biliography

Page 58: LaTeX Tutorial

.bib key-value @article{MCCSurvey, author = {Fernando, Niroshinie and Loke, Seng W. and Rahayu, Wenny}, title = {{Mobile Cloud Computing: A Survey}}, journal = {Future Gener. Comput. Syst.}, issue_date = {January, 2013}, volume = {29}, number = {1}, month = jan, year = {2013}, issn = {0167-739X}, pages = {84--106}, numpages = {23}, url = {http://dx.doi.org/10.1016/j.future.2012.05.023}, doi = {10.1016/j.future.2012.05.023}, acmid = {2388260}, publisher = {Elsevier Science Publishers B. V.}, address = {Amsterdam, The Netherlands, The Netherlands}, keywords = {Mobile cloud computing, Pervasive networks, Task offload}, }

Page 59: LaTeX Tutorial

Best Practices

• survey bib

• title

• Google Scholar BibTeX

Page 60: LaTeX Tutorial

• \addcontentsline{toc}{chapter}{\bibname}

• \bibliography{bib_file_name}

• \usepackage[notbib]{tocbibind}

Page 61: LaTeX Tutorial

• Mac xelatex bibtex

• xelatex thesis.tex

• bibtex thesis.tex

• xelatex thesis.tex

• xelatex thesis.tex

• Linux pdftex

Page 62: LaTeX Tutorial

1. xelatex thesis.tex: xelatex \cite thesis.aux

2. bibtex thesis.tex: bibtex thesis.aux key .bib values

thesis.bbl 3. xelatex thesis.tex: xelatex .bbl

\bibliography{…} 4. xelatex thesis.tex:

BibTeX

Page 63: LaTeX Tutorial

• definecolor

• lstdefinelanguage

• hyphenation

• pdfpages

• listoffigures listoftables

• vspace noindent

Page 64: LaTeX Tutorial

definecolor• \definecolor{my_red}{RGB}{223,0,2}

{

\color{my_red}

This sentence is red.

}

Page 65: LaTeX Tutorial

lstdefinelanguage\lstdefinelanguage{JavaScript}{ keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, if, in, while, do, else, case, break}, keywordstyle=\color{jskw}\bfseries, ndkeywords={class, export, boolean, throw, implements, import, this}, ndkeywordstyle=\color{darkgray}\bfseries, identifierstyle=\color{black}, sensitive=false, comment=[l]{//}, morecomment=[s]{/*}{*/}, commentstyle=\color{jsgreen}\ttfamily, stringstyle=\color{jsred}\ttfamily, morestring=[b]', morestring=[b]" }

Page 66: LaTeX Tutorial

… lstset

\lstset{ language=JavaScript, numbers=none, tabsize=2, basicstyle=\ttfamily\small, breakatwhitespace=true }

Page 67: LaTeX Tutorial

Hyphenation• LaTeX

• hyphenation • \hyphenation{Java-Script}

Page 68: LaTeX Tutorial

pdfpages

• \usepackage{pdfpages}

\addcontentsline{toc}{chapter}{ }

\includepdf[pages={1}]{cert.pdf}

Page 69: LaTeX Tutorial

listoffigures & listoftables

• \listoffigures \listoftables

• \tableofcontents

Page 70: LaTeX Tutorial

vspace

• \vspace{5mm}

• v = verticle

• 5mm

Page 71: LaTeX Tutorial

noindent

• \noindent

Page 72: LaTeX Tutorial

Best Practices• \input \input • • ~ • e.g. i.e. • \emph \textbf \texttt • itemize enumerate • build.sh makefile • Google Scholar bib • Git Github Bitbucket

• TeX .gitignore • https://www.gitignore.io/api/latex