Lecture 3 LaTeX and LyX

advertisement
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 OS
 Install 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
\documentclass{…}
\usepackage{…}
\begin{document}
…Write your text here…
\end{document}
Try to do yourself!
Introduction to academic studies
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
\usepackage[swedish]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
Introduction to academic studies
Titles, chapters and sections

1.
2.
3.
4.
5.
Define the frontpage:
\title{…}
\documentclass[12pt]{paper}
\author{…}
%Some more commands here, skipped
\begin{document}
\date{…}
\title{Bootstrap confidence intervals for large-scale multivariate
monotonic regression problems}
\maketitle
\author{Oleg Sysoev, Anders Grimvall, Oleg Burdakov }
\maketitle
\section
\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}
Introduction to academic studies
Alignment

\begin{x} … \end{x}

x = flushleft flushright or center
\section{Introduction}\label{intro}
\begin{center}
Monotonic regression is a nonparametric method...
\end{center}
Introduction to academic studies
Quotation

Use quote environment
As it is specified in \cite{strand}:
\begin{quote}
Unfortunately, there are no efficient MR algorithms
when ...
\end{quote}
Introduction to academic studies
Referencing

Use \label{} and \ref{}

Proper in many situations: formulas, tables, graphs,
chapters…
\section{Introduction}\label{intro}
As it is specified in section \ref{intro}...
Introduction to academic studies
Font sizes and styles

Bold \textbf{…}
Italic \textit{…}

Small font {\small ….}

{\scriptsize
\begin{tabular}{l | c l l l l l l c l l l l l l}
…
\end{tabular}
}
Introduction to academic studies
Formulas



Formula in the text $...$
Formula at the new line:
\begin{equation}…\end{equation}
Formula at the new line without number: \[ … \]
\begin{equation}
Y_i=\phi(X_i, \theta)+ \epsilon_i \label{addit}
\end{equation}
Introduction to academic studies
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 ”\\”
\[
\mathbf{X} = \left(
\begin{array}{ccc}
x_1 & x_2 & \ldots \\
x_3 & x_4 & \ldots \\
\vdots & \vdots & \ddots
\end{array} \right)
\]
Introduction to academic studies
Arrays, matrices
\begin{equation}
Y=\left\{
\begin{array}{rl}
e^x,& if \: x>0,\\
\sqrt{x^2+1},& otherwise
\end{array} \right.
\end{equation}
Introduction to academic studies
Creating tabbing


Define position by \=
Move to the position by \>
\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}
Introduction to academic studies
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
\begin{tabular}{|l|ccc|}
\hline
$\frac{Bootstrap\ method}{CI\ approach}$ & $Parametric$
&$\stackrel{Non-parametric,}{mid-point}$ & $\stackrel{Nonparametric,}{worst-case}$\\
\hline
Percentile& Method 1 & Method 3 & Method 5 \\
BCa& Method 2 & Method 4 & Method 6\\
\hline
\end{tabular}
Introduction to academic studies
Creating tables

To merge several cells, use \multicolumn or \multirow:
{\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}$ \\
\hline
0.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}
}
Introduction to academic studies
Creating tables


\usepackage{multirow}
\multirow{''num_rows''}{''width''}{''contents''}.
\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}
Introduction to academic studies
Floating tables
Sometimes tables and graphs are large to be placed directly after a
specific text  automatic placement

Placement:




h= here
t=top
b=bottom
p=at the special page
\begin{table}[placement or nothing]
\begin{tabular}{...}
...
\end{tabular}
\caption{}
\label{}
\end{table}
Introduction to academic studies
Floating tables
\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}
Introduction to academic studies
Including graphics

For publication, eps-format is normal.


\usepackage[dvips]{graphicx}
\includegraphics[width=,height=,scale=, angle=]{filename}
\includegraphics[width=10cm]{f10k.eps}
Introduction to academic studies
Floating graphics
\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}
Introduction to academic studies
Bibliography

To write bibliography, use
\begin{thebibliography}{99}
\bibitem{marker} TEXT…
\bibitem{marker} TEXT…
…
\end{thebibliography}

Cite:

\cite{marker}
Introduction to academic studies
Bibliography
\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}
Introduction to academic studies
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
Download