22
Dr. Corcoran – STAT 6550 Mathematics and Statistics LTX LaTeX Began as TeX, in 1982 (Knuth). Purely a typesetting tool. LaTeX added macros, maintaining TeX as it’s typesetting engine (Lamport). Now maintained by Frank Mittlebach. For an interesting interview, see: http://www.freesoftwaremagazine.com/articles/mittelbach_interview

LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

L T XLaTeX

• Began as TeX, in 1982 (Knuth). Purely a typesetting g , ( ) y yp gtool.

• LaTeX added macros, maintaining TeX as it’s typesetting engine (Lamport).

• Now maintained by Frank Mittlebach. For an interesting interview, see:http://www.freesoftwaremagazine.com/articles/mittelbach_interview

Page 2: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Typesetting

• We are accustomed to What You See Is What You Get (WYSIWYG) tools – such as this Powerpoint presentation.

• WYSIWYG seldom results in an aesthetically pleasing publication.pleasing publication.

Page 3: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

“Advantages” (from http://www.ctan.org/tex-Advantages (from http://www.ctan.org/texarchive/info/lshort/english/lshort.pdf)

• Professionally crafted layouts are available whichProfessionally crafted layouts are available, which make a document really look as if “printed.”

• The typesetting of mathematical formulae is supported in a convenient way.

• Users only need to learn a few easy-to-understand commands that specify the logical structure of acommands that specify the logical structure of a document. They almost never need to tinker with the actual layout of the document.

• Even complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily.be generated easily.

Page 4: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

“Advantages” (from http://www.ctan.org/tex-Advantages (from http://www.ctan.org/texarchive/info/lshort/english/lshort.pdf)

• Free add-on packages exist for many typographicalFree add on packages exist for many typographical tasks not directly supported by basic LaTeX. For example, packages are available to include P tS i t hi t t t bibli hiPostScript graphics or to typeset bibliographies conforming to exact standards. Many of these add-on packages are described in The LaTeX Companion.

• LaTeX encourages authors to write well-structured texts, because this is how LaTeX works—by specifying structurespecifying structure.

• TeX, the formatting engine of LaTeX2e, is highly portable and free. Therefore the system runs on p yalmost any hardware platform available.

Page 5: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

“Disadvantages” (from http://www.ctan.org/tex-Disadvantages (from http://www.ctan.org/texarchive/info/lshort/english/lshort.pdf)

• LaTeX does not work well for people who have sold their souls . . .LaTeX does not work well for people who have sold their souls . . .• Although some parameters can be adjusted within a predefined document

layout, the design of a whole new layout is difficult and takes a lot of time.• It is very hard to write unstructured and disorganized documents• It is very hard to write unstructured and disorganized documents.• Your hamster might, despite some encouraging first steps, never be able

to fully grasp the concept of Logical Markup. (From another source: “There are two major classes of text markup: logical and physical LogicalThere are two major classes of text markup: logical and physical. Logical markup indicates the role of a text segment, such as being more important than normal text or being a citation. Physical markup is an instruction to present text in a particular manner, such as using a font of st uct o to p ese t te t a pa t cu a a e , suc as us g a o t osome specific kind or underlining.”)

Page 6: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

How to startHow to start…• Need LaTeX available for your system.

I t ASCII fil O t t th ti ll l i• Input: an ASCII file. Output: an aesthetically pleasing typeset document.

• Components of a LaTeX input file:Components of a LaTeX input file:– Preamble, including

• a specification of the document “class” (or type),• specification of non-default document settings

(margins, etc.),t f i l i f th t d d• requests for inclusion of other nonstandard

“packages” (must be available locally).– Document body.Document body.

Page 7: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and StatisticsExample – Input\documentclass{article}\usepackage{graphics}\usepackage{graphics}\setlength{\oddsidemargin}{0in} \setlength{\textwidth}{6.0in}\setlength{\textheight}{10in} \setlength{\topmargin}{-0.5in}\begin{document}

\setlength{\parindent}{0in} \setlength{\parskip}{2ex}

\begin{center}{\bf \Large STAT 6550 -- SPRING 2014

Homework 1

\vspace{2ex}

\normalsize Due Tuesday February 4th}\end{center}

\raggedright

\vspace{2ex}

\begin{enumerate}

\item Obtain documentation for \LaTeX\ -- select something that you can use as afairly comprehensive desk reference. Specify in your homeworkwrite-up what you have selected and why.

Page 8: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and StatisticsExample – Input (continued)

\item Obtain and install \LaTeX\ on your own computer, or identify another point of\item Obtain and install \LaTeX\ on your own computer, or identify another point ofaccess to \LaTeX\ (e.g., in a student computing lab). Briefly describe whereyou will use \LaTeX, including the machine, platform, the front-end (editing)program, and where you obtained the source code for installation (if youinstalled \LaTeX\ yourself).

\item Turn in a solution for the following problem: Suppose that $X \sim\mathrm{Binomial}(n,p)$. {\bf (a)} Show that the maximum likelihood estimator(MLE) of $p$ is $\hat{p}=X/n$. {\bf (b)} Show that the MLE attains theCramer-Rao lower bound. {\bf (c)} If $n=10$ and $X=5$, plot the loglikelihood function. Use software to obtain this plot, and include the plot inthe body of your solutionthe body of your solution.

\end{enumerate}

\end{document}

Page 9: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and StatisticsExample – Output

Page 10: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

LaTeX Resources• TeX Users Group (TUG) – http://www.tug.org

• Comprehensive TeX Archive Network – http://www.ctan.org

• MiKTeX (TeX for Windows) – http://www.miktex.org

• WinEdt (commercial front-end interface for editing TeXdocuments in Windows) – http://www.winedt.com) p

Page 11: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

LaTeX Resources (continued)

• Free documentation: The Not So Short Introduction to LaTeX2e –htt // t /t hi /i f /l h t/ li h/l h t dfhttp://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf

• More free documentation: A Gentle Introduction –• More free documentation: A Gentle Introduction –http://ctan.tug.org/tex-archive/info/gentle/gentle.pdf

Page 12: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Creating a Document• Specify the document class (with options).

• Specify settings.

• Begin document.

• Include text.

• End document.

Running the document through TeX (without errors) yields a .dvi file, which must be viewed in some sort of dvi window.

Page 13: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

The Document ClassSome basic types :

• Article (far and away the most common – what I use 99.9% of th ti )the time).

• Book• Book

• Slides (for presentations)( p )

• Letter

Page 14: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

SettingsBefore beginning the document, specify parameters

corresponding to:

M i• Margins• Page size• Size of text body• Size of text body• Header and footer locations• Information about titles, dates, etc., ,

(See the handout regarding parameters for page settings.)

Page 15: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Characters in the Input File• Upper and lowercase letters, and the ten digits (recall that in

ASCII, the letter “O” is distinguishable from the digit zero “0”.

Sixteen punctuation characters: ? ! ` ‘ ( ) [• Sixteen punctuation characters: . : ; , ? ! ‘ ( ) [ ] - / * @

• Ten “special” characters (used only in LaTeX commands): # $ % & ~ _ ^ \ { }

• The characters + = | < > are used mainly in math formulas although + and = can be used in regular textformulas, although + and = can be used in regular text.

Page 16: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Special Environments/Tools: DisplayedSpecial Environments/Tools: Displayed Text

• Quotes: \begin{quote} and \end{quote}.

• Descriptive lists (like glossaries): \begin{description}and \ d{d i ti } Each item is specified using theand \end{description}. Each item is specified using the\item[name] Description here.

• Lists (like “bullet” items): \begin{list} and \end{list}. Each item prefixed with \item. Lists can be nested.

• Numbered lists: \begin{enumerate} and\end{enumerate} Each item prefixed with \item\end{enumerate}. Each item prefixed with \item.

Page 17: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Math ExampleMath ExampleThis following text (imbedded in a document) results in the output shown on the following page.The bootstrap p-value is obtained by resampling from the reference set, $\Gamma$, of all $2 \times 4$ tables with column sums equal to 10. Under $H_{0}$ the probability of observing any $\xb \in \Gamma$ is\begin{equation}f {\pi}(\xb) = \prod {j=1}^{4} {10 \choose x {j}}\pi^{x {j}} (1 - \pi)^{10-f_{\pi}(\xb) \prod_{j 1} {4} {10 \choose x_{j}}\pi {x_{j}} (1 \pi) {10x_{j}} \ , \label{eq:binexact}\end{equation}a product of four binomial probabilities. It is not possible to resample tablesFrom $\Gamma$ with probabilities given by (\ref{eq:binexact}) because $\pi$, the

i i i $ 0 $ i $\ i$Bernoulli probability under $H_{0}$, is unknown. We can, however, replace $\pi$ with\[\hat{\pi} = \frac{5}{40} \ ,\]\]the maximum likelihood estimate (mle) under the null hypothesis. The bootstrap p-value is then evaluated by resampling tables from $\Gamma$ with probabilities given by\begin{equation} f {\hat{\pi}}(\xb {j}) \prod {j 1}^{4} {10 \choose x {j}}\hat{\pi}^{x {j}}f_{\hat{\pi}}(\xb_{j}) = \prod_{j=1}^{4} {10 \choose x_{j}}\hat{\pi}^{x_{j}}(1 - \hat{\pi})^{10-x_{j}} \ . \label{eq:binboot}\end{equation}

Page 18: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

M th E l R ltMath Example: Result

Page 19: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Special Environments/Tools: Tables• Delimited with \begin{tabular} and \end{tabular}.

• Number of columns is specified up-front, with argument to . For example \b i {t b l }[l ] specifies that weFor example, \begin{tabular}[lcr] specifies that we will have three columns: the first left-justified, the second centered, and the third right-justified.

• Within each row, columns are separated by the & symbol.

• A row is completed by using the command \\ for a new line.

Page 20: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Tables ExampleThis:

\begin{tabular}{||l|ccc|c||}\hline\multicolumn{5}{||c||}{Stratum 1: Women using O.C. Aged 25-29} \\\hline& \multicolumn{3}{|c|}{Cigarettes Smoked (per day)} & \\ \cline{2-4} \multicolumn{1}{||c|}{Disease Status} & \multicolumn{1}{|c}{none} & \multicolumn{1}{c}{1to 24} & \multicolumn{1}{c|}{more than 24} & \multicolumn{1}{c||}{Total} \\ \hlineM.I. & 0 & 1 & 3 & 4 \\Control & 25 & 25 & 12 & 62 \\ \hline

produces this:

\end{tabular}

Page 21: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Special Environments/Tools: Pictures and Graphicsp p

Particularly in scientific documents, inclusion of plots or charts is generally required. A graphics package is required, included at the beginning of the document with something like\include{graphics} (this package is included with generally all versions, although system-dependent variationsgenerally all versions, although system dependent variations exist – it allows inclusion of postscript and encapsulated postscript files).

To include a plot at some point in the document, one might use something like

\i l d hi [ ti ]{fil h }\includegraphics[options]{filename here}.

The picture environment (delimited with \begin{picture}and \end{picture}) allow one to draw shapes in theand \end{picture}) allow one to draw shapes in the document.

Page 22: LTXLaTeX - USU\vspace{2ex} \normalsize Due Tuesday February 4th} \end{center} \raggedright \vspace{2ex} \begin{enumerate} \item Obtain documentation for \LaTeX\ -- select something

Dr. Corcoran – STAT 6550Mathematics and Statistics

Special Environments/Tools: Bibliography• Requires a database file of citations, formatted in a special

way:y@ARTICLE{CMS, AUTHOR = "Corcoran, C. and Mehta, C. and Senchaudhuri, P.", TITLE = "Power Comparisons for Tests of Trend in Dose-Response Studies"Studies", JOURNAL = "Statistics in Medicine", VOLUME = "19", PAGES = "3037-3050", YEAR = "2000" }

• Given this .bib file, one can easily include citations in the t t i th d

YEAR = "2000" }

text via the \cite{CMS} command.

• Must follow a series of steps to achieve proper formatting.

• Wide variety of journal-specific styles are available.