Lecture 3 LaTeX and LyX. LaTeX TeX Computer program by Donald Knuth for typesetting text and...

Post on 25-Dec-2015

222 views 0 download

Transcript of Lecture 3 LaTeX and LyX. LaTeX TeX Computer program by Donald Knuth for typesetting text and...

Lecture 3

LaTeX and LyX

LaTeX

TeX Computer program by Donald Knuth for typesetting text

and formulas (1977)

LaTeX Predefined professional layout You need to write code to create documents ( for ex.

scientific papers) Code is compiled to PDF or PS or other files

LyX Graphical interface that allows using mouse instead of

writing codes (compare: Word) Produces LaTeX code that you can see and compile

Introduction to academic studies

LaTeX vs MS Word

LaTeX is more often used for writing scientific reports and papers Once publisher provides it’s style file, it can be embedded

into your TeX file easily (in Word, you need to adjust the style manually may take hours or days)

Formulas can be enumerated and updated automatically (one new formula is inserted – not a big deal, compare with Word)

There is a citation and referencing function (in Word, manually)

Word provides a better grammar control tool than LaTeX

Introduction to academic studies

Installing LaTeX and LyX

Windows OSInstall MikTeX http://www.miktex.org/Install an editor, TeXnicCenter (if you do not plan to use LyX): http://www.texniccenter.org/Install LyX if you like graphical interface: http://www.lyx.org/

Introduction to academic studies

Document structure

Try to do yourself!

Introduction to academic studies

\documentclass{…}

\usepackage{…}

\begin{document}

…Write your text here…

\end{document}

Text, characters and comments

New line is ignored Make a blank line to begin a new line

Several ”space”s treated as a single one # $ % ^ & _ { } ~ \ can not be used in text directly

use \# \$ \% … LaTeX commands are case sensitive LaTeX commands start with backslash

\command[optional param]{parameter} Comments start with %

Introduction to academic studies

Document classes

\documentclass[options]{class} class

article proc (Proceedings) report (small book, thesis) book slides

options 10pt, 11pt, 12pt (size of main font) a4paper, a5paper,… onecolumn, twocolumn twoside, oneside landscape …

Introduction to academic studies

Language support

Swedish

Introduction to academic studies

\usepackage[swedish]{babel}

\usepackage[T1]{fontenc}

\usepackage[latin1]{inputenc}

Titles, chapters and sections

Define the frontpage:

1. \title{…}

2. \author{…}

3. \date{…}

4. \maketitle

5. \section

Introduction to academic studies

\documentclass[12pt]{paper}

%Some more commands here, skipped

\begin{document}

\title{Bootstrap confidence intervals for large-scale multivariate monotonic regression problems}

\author{Oleg Sysoev, Anders Grimvall, Oleg Burdakov }

\maketitle

\begin{abstract}

Monotonic regression (MR) computes a response that is increasing or decreasing with respect to each of explanatory variables...

\end{abstract}

\textbf{Keywords: }Confidence intervals, monotonic regression, bootstrap,

percentile...

\section{Introduction}\label{intro}

...

\end{document}

Alignment

\begin{x} … \end{x} x = flushleft flushright or center

Introduction to academic studies

\section{Introduction}\label{intro}

\begin{center}Monotonic regression is a nonparametric method...\end{center}

Quotation

Use quote environment

Introduction to academic studies

As it is specified in \cite{strand}:\begin{quote}Unfortunately, there are no efficient MR algorithms when ...\end{quote}

Referencing

Use \label{} and \ref{} Proper in many situations: formulas, tables, graphs,

chapters…

Introduction to academic studies

\section{Introduction}\label{intro}As it is specified in section \ref{intro}...

Font sizes and styles

Bold \textbf{…} Italic \textit{…}

Small font {\small ….}

Introduction to academic studies

{\scriptsize\begin{tabular}{l | c l l l l l l c l l l l l l}…\end{tabular}}

Formulas

Formula in the text $...$ Formula at the new line: \begin{equation}…\

end{equation} Formula at the new line without number: \[ … \]

Introduction to academic studies

\begin{equation}Y_i=\phi(X_i, \theta)+ \epsilon_i \label{addit}\end{equation}

Formulas: building blocks

Subscript: $X_i$ $A_{low}$ Superscript: $x^2$ $Y^{t^2}$ Greek letters: \lambda \Phi \phi… Comparison: > < = \geq \leq Square root: \sqrt{x^3} Ratio $\frac{x}{y^2+1}$ Product $A \cdot B$ $\hat{Y}$, $\vec{X}$ Brackets $\left( X^2+1 \right )$ Series of sums, product: \sum and \prod

$Y_i= \sum_{j=1}^{n_i} Y_{ij}/n_i$ Integral \int

Introduction to academic studies

Arrays, matrices

Use array environment: Use ”c” ,”l” or ”r” for alignment Separate elements with ”&” End line with ”\\”

Introduction to academic studies

\[

\mathbf{X} = \left(

\begin{array}{ccc}

x_1 & x_2 & \ldots \\

x_3 & x_4 & \ldots \\

\vdots & \vdots & \ddots

\end{array} \right)

\]

Arrays, matrices

Introduction to academic studies

\begin{equation}

Y=\left\{

\begin{array}{rl}

e^x,& if \: x>0,\\

\sqrt{x^2+1},& otherwise

\end{array} \right.

\end{equation}

Creating tabbing

Define position by \= Move to the position by \>

Introduction to academic studies

\begin{tabbing}1. \ \=Compute the fitted response values $\hat{Y}_1, \ldots, \hat{Y}_n$ \\\> and block partition $B_1, \ldots, B_K$ by applying SBR\\ 2. \>For \= each $j=1, \ldots, B$ and $i=1, \ldots, n$\\\>\>Find $k$ such that $i \in B_k$. \\\>\>Compute $l$ by sampling from $B_k$\\\>\>Set $Y^*_{ij}=Y_{l}$\\\end{tabbing}

Creating tables

Use \begin{tabular}[pos]{table_spec} …\end{tabular} Use ”c” ,”l” or”r” for alignment. For a fixed width, use

p{width}. For drawing of vertical lines, use ”|” Separate elements with ”&” End line with ”\\” Draw lines with \hline

Introduction to academic studies

Creating tables

Introduction to academic studies

\begin{tabular}{|l|ccc|}\hline$\frac{Bootstrap\ method}{CI\ approach}$ & $Parametric$ &$\stackrel{Non-parametric,}{mid-point}$ & $\stackrel{Non-parametric,}{worst-case}$\\\hlinePercentile& Method 1 & Method 3 & Method 5 \\BCa& Method 2 & Method 4 & Method 6\\\hline\end{tabular}

Creating tables

To merge several cells, use \multicolumn or \multirow:

Introduction to academic studies

{\scriptsize\begin{tabular}{l | c l l l l l l c l l l l l l}& \hspace{2mm} & \multicolumn{6}{l}{$n=10,000$} & \hspace{3mm} & \multicolumn{6}{l}{$n=50,000$}\\\hline$Slope$ & &$dev$ & $t_{seg}$ & $t^{tot}_{gpav}$ & $t_{gpav}$ & $m_{seg}$ & $m_{gpav}$ & &$dev$ & $t_{seg}$ & $t^{tot}_{gpav}$ & $t_{gpav}$ & $m_{seg}$ & $m_{gpav}$ \\\hline0.2 & & 0.63 & 10.9& 35.3 & 6.6 & 28.4 & 253.6 & & 0.72 & 128.3 & 1152.3 & 142.6 & 32.6 & 1876.3\\2 & & 1.38 & 25.1& 30.8 & 1.4 & 37.2 & 253.4 & & 6.80 & 397.9 & 1046.2 & 26.1 & 181.0 & 1878.2\\\hline\end{tabular}}

Creating tables

\usepackage{multirow} \multirow{''num_rows''}{''width''}{''contents''}.

Introduction to academic studies

\begin{tabular}{ |l|l|l| }\hline\multicolumn{3}{ |c| }{Registered breakpoints} \\\hline 1981 & January & 13.7 \\ \hline\multirow{2}{*}{1982} & February & 12.6 \\ & March & 13.9 \\\hline\end{tabular}

Floating tables

Sometimes tables and graphs are large to be placed directly after a specific text automatic placementPlacement:

h= here t=top b=bottom p=at the special page

Introduction to academic studies

\begin{table}[placement or nothing]\begin{tabular}{...}...\end{tabular}\caption{}\label{}\end{table}

Floating tables

Introduction to academic studies

\begin{table}[b]

\begin{tabular}{ |l|l|l| }…\end{tabular}\caption{Registered breakpoints in the time series of oil consumption, mtones.}\label{oil}\end{table}

Including graphics

For publication, eps-format is normal. \usepackage[dvips]{graphicx} \includegraphics[width=,height=,scale=, angle=]{filename}

Introduction to academic studies

\includegraphics[width=10cm]{f10k.eps}

Floating graphics

Introduction to academic studies

\begin{figure}\includegraphics[...]{filename}\caption{…}\label{…}\end{figure}

\begin{figure}\centering\begin{tabular}{cc}\includegraphics[height=4.3cm]{time10K} & \includegraphics[height=4.3cm]{f10K} \\\end{tabular}\caption{Processing time $Time$(to the left) and objective function $SSR$(to the right)}\label{fig2}\end{figure}

Bibliography

To write bibliography, use

Cite: \cite{marker}

Introduction to academic studies

\begin{thebibliography}{99}

\bibitem{marker} TEXT…

\bibitem{marker} TEXT…

\end{thebibliography}

Bibliography

Introduction to academic studies

\newpage...we presented an algorithm called GPAV (Generalized PAV)which is a generalization of the PAV algorithm \cite{ayer}.

\begin{thebibliography}{99}

\bibitem{ayer}Ayer, M., Brunk, H.D., Ewing, G.M., Reid, W.T., Silverman, E.: An empirical distribution function for sampling with incomplete information. The Annals of Mathematical Statistics 26, 641--647 (1955)

\bibitem{barlow}Barlow, R.E., Bartholomew, D.J., Bremner, J.M., Brunk, H.D.: Statistical inference under order restrictions. Wiley, New York (1972)

\end{thebibliography}

LyX

Introduction to academic studies

Home reading

http://ctan.tug.org/tex-archive/info/lshort/english/lshort.pdf

http://www.latex-project.org/

http://www.lyx.org/

Introduction to academic studies