latex a document preparation system
DESCRIPTION
Latex A document preparation system. All academic staff in Computer Science publish their work using Latex – NOT Microsoft Word. Why? Note to self – press ctrl key to show pointer. Outline. What is latex and why learn it . How does it compare to word processors. - PowerPoint PPT PresentationTRANSCRIPT
LatexA document preparation system
All academic staff in Computer Science publish their work using Latex – NOT Microsoft Word.
Why? Note to self – press ctrl key to show pointer
Outline
1. What is latex and why learn it. 2. How does it compare to word processors. 3. The basic method of producing documents4. Some basic commands5. Where to go for more information…Google
Have you ever….?1. Saved a word file at university2. Then taken it home and opened it on a
different computer, only to find all of the formatting is different.
3. Latex is platform independent. You can give a tex file to someone to run on any computer.
4. Latex is for scientific/technical documents.
What is latex
1. It is a document preparation package2. Compare with notepad (a text editor),
Microsoft word (a word processor) and e.g. eclipse (a programming environment).
3. It is a mark up language (like html)4. In Internet Explorer go to View Source and
you can see the code for a webpage. 5. http://scottmcpeak.com/latex/whatislatex.ht
ml
Why learn latex
1. Latex is harder to learn that Microsoft word - initially.2. In the longer term you will see the benefits. 3. It will be around for years (and has been). 4. It produces more professional results compared to
WYSIWYG (what you see is what you get) type word processing packages.
5. There is a strong community of users on the internet (user groups, forums e.g. http://latex-community.org/).
6. Publishing is often encouraged in latex (rather than MS word).
7. Lots of good tutorials on-line
Comparison Word vs Latex
1. MS word is a single file e.g. CV.doc.2. Wysiwyg (what you see is what you get) 3. Latex uses (at least) two files, a source file
(input) and a target file (output). E.g CV.tex and CV.pdf
4. In Word, you highlight text with a mouse and make it bold/underlined/change font size…
5. In Latex, you surround the text with a command e.g \emph{John} emphasizes the word “John”
6. http://openwetware.org/wiki/Word_vs._LaTeX
Command line or Icons
1. It can be run from the command line. 2. Basic commands are
1. latex file.tex2. bibtex file.tex3. pdflatex file.tex
3. It can also be run via software (e.g. http://www.winedt.com/), many of which are freely available.
Special Characters
1. Most characters on the keyboard, have their usual meaning “abc123”.
2. However the characters \ { } $ ^ _ % ~ # & are used for special purposes
3. \# \$ \% \& \_ \{ \}4. \, ^ and ~ cannot be produced simply by preceding
them with a backslash. They can however be produced using \char92 (in the \texttt font only), \char94 and \char126 respectively.
Comments %
• You can skip or ignore a line by placing % in front% this line is not printed This line will be printed• Unfortunately there is no way to comment
multiple lines except by doing it individually. % line 1 is ignored% line 2 is ignored• However many graphical editors do allow this.
control sequences.
1. consist of a backslash \ followed by a string of (upper or lower case) letters.
2. \delta produces the greek letter , 3. \emph{hi}, emphasized (italic font), hi4. \to (or \rightarrow) produces the arrow -->.
mathematics mode
1. The special character $ is used when embedding mathematical expressions in paragraphs of ordinary text in order to change into and out of `mathematics mode'.
2. The special characters ^ and _ are used in mathematical expressions to produce superscripts and subscripts respectively.
3. \begin{equation} f(x) = 4x + 11 \end{equation}4. A backslash \ can be obtained in mathematics mode
by typing \backslash.
Greek letters and math symbols
Just Google “Greek letters latex” or “latex math symbols”. Here are a few I have found. 1. http://www.maths.tcd.ie/~
dwilkins/LaTeXPrimer/MathSymb.html2. http://www.maths.tcd.ie/~dwilkins/LaTeXPri
mer/GreekLetters.html
Work through the following (eg. 2)1. \documentclass[a4paper,12pt]{article}2. \begin{document}3. \emph{analysis}4. $D$ 5. $\bf R$ 6. $f \colon D \to \mathbf{R}$ 7. $\epsilon > 0$ 8. $x \in D$,9. $\delta > 0$ 10.\end{document}
Producing White Space in LaTeX
1. “white space” is ignored by latex. 2. \hspace{20 mm}. Horizontal space of 20 mm3. \vspace{10 mm}. Vertical space of 10 mm4. \noindent Will not indent the next paragraph. 5. Mr.\ Smith' 6. ~ represents a blank space at which LaTeX is
not allowed to break between lines7. To obtain `W. R. Hamilton' it is best to
type W.~R.~Hamilton.
List environmentsLaTeX provides the following list environments:1. enumerate for numbered lists,
2. \begin{enumerate} … \end{enumerate}3. itemize for un-numbered lists, 4. \begin{itemize} ... \end{itemize}5. description for description lists6. \begin{description} … \end{description}
Tables
1. \begin{tabular} command 2. the string {lll} is a format specification for a table
with three columns of left-justified text.3. \begin{tabular}{|r|r|} two columns of right-justified4. the ampersand character & is used to separate
columns of text within each row, 5. the double backslash \\ is used to separate the rows
of the table.6. the command \hline produces a horizontal line
Accents
1. There are a variety of control sequences for producing accents. For example, the control sequence \'{o} produces an acute accent on the letter o. Thus typing
2. Se\'{a}n \'{O} Cinn\'{e}ide.3. Again, to find more – I encourage you to just
Google “latex accents”
Define Your own commands.
1. \[ \int_{-\infty}^{+\infty} f(x)\,dx.\] 2. \newcommand{\inftyint}{\int_{-\infty}^{+\infty}}3. \[ \inftyint f(x)\,dx.\] 4. \newcommand{\intwrtx}[1]{\int_{\infty}^{+\
infty} #1 \,dx}5. \[ \intwrtx{f(x)}.\] 6. \newcommand{\intwrt}[2]{\int_{-\infty}^{+\
infty} #2 \,d #1}7. \[ \intwrt{y}{f(y)}.\]
Theorems, proofs, lemmas, …
1. \begin{theorem} … \end{theorem}. 2. \begin{lemma} ... \end{lemma} 3. \begin{proof}….\qed \end{proof}4. \label{name} 5. \ref{name}
Fractions and Roots
1. To print a fraction we type2. \frac{numerator}{denominator}.3. To print a square root4. \sqrt{expression}.5. To print the n-th root6. \sqrt[n]{expression}.
Brackets and Norms
1. (, [ and {, which are obtained by typing (, [ and \{ respectively.
2. The corresponding right delimiters are of course obtained by typing ), ] and \}.
3. In addition | and || are used as both left and right delimiters, and are obtained by typing | and \| respectively.
4. large parentheses is to type \left( for the left parenthesis and \right) for the right parenthesis,
Matrices.
1. Matrices are important for a number of application in engineering.
2. You will probably use Matlab to do the calculations
3. But you can use Latex to produce the documentation
4. http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Matrices.html
What to do if you get an error.
1. PC for John Woodward2. you should compile the tex file every few
minutes so you can see immediately if you have made a mistake.
3. Unfortunately, the error is not always where you think it is. Some detective work may be necessary.
4. Pay attention to the error messages.
Bibtex 1
To cite a work or paper \cite{Narendra_1990}The following two commands go at the end of the docuementTo choose a style \bibliographystyle{plain} Put your references in a separate file myref.bib \bibliography{myrefs} "myrefs.bib" \end{document}See http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.html
Bibtex 2• You need to compile the bibtex file.• Suppose you have article.tex and article.bib. You need to run:• latex article.tex (this will generate a document with question
marks in place of unknown references)• bibtex article (this will parse all the .bib files that were included
in the article and generate meta information regarding references)
• latex article.tex (this will generate document with all the references in the correct places)
• latex article.tex (just in case if adding references broke page numbering somewhere)
• Or you could write a script with these commands (see Cygwin lecture)
Document classes
You have been article style today but there are other styles • book, • report • letter• http://www.latextemplates.com/
Where to find out more
• Just Google latex with different combinations (see the earlier lecture on Google).
• http://www.latexeditor.org/• www.winedt.com/ • miktex.org/
weblinks
• http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
• http://tobi.oetiker.ch/lshort/lshort.pdf• http://en.wikibooks.org/wiki/LaTeX/Introducti
on• http://www.miktex.org/• http://
www.tex.ac.uk/cgi-bin/texfaq2html?label=verbfile
• http://www-h.eng.cam.ac.uk/help/tpl/textprocessing/
NASA and Love letters
1. NASA uses latex2. http://www.giss.nasa.gov/tools/latex/ltx-2.ht
ml3. Next time you write a love letter to your
girl/boy friend – Don’t handwrite it – don’t use word – use latex