1 / 51

Introduction to LaTeX

Learn about LaTeX, a document markup language and preparation system, and its advantages over MS Word. Discover the tools required, various output formats, and how to structure a LaTeX document.

tomcase
Download Presentation

Introduction to LaTeX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to LaTeX C151 Multiuser Operating Systems

  2. What is LaTex • LaTeX is a document markup language and document preparation system.

  3. Why LaTeX? • LaTeX Separate contents from style • Word WYSIWYG

  4. Why not MS Word?

  5. Why LaTeX? • Portable and free • Professionally crafted layouts are available • The typesetting of mathematical formulae is supported in a convenient way • Output: many different formats • Users need only to learn a few simple commands, which specify the logical structure of a document • Complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily

  6. Required Tools • Editor: • TeXnic • Winedt • Input file: • The input for LaTeX is a plain text file with extension “.tex” • You can create it with any text editor. • It contains: the text of the document and commands which tell LaTeX how to typeset the text. • Compiler (www.miktex.org) • Standard installation for Linux • Windows • Mac

  7. Output Formats • .dvi Device Independent • .ps Post Script • .pdf PDF • .rtf Rich Text Format • .html HTML

  8. Compile LaTeX • Generate a dvi file: >latexfile_name.tex • Generate a pdf file >pdflatexfile_name.tex

  9. Documents Structure (1) • Every LaTeX document must contain the following three components: \documentclass{article} \begin{document} \end{document}

  10. Document Structure (2) • Every input file starts with the command:\documentclass{...} • When all the setup work is done, you start the body of the text with the command:\begin{document} • Now you enter the text mixed with some useful LaTeX commands. • At the end of the document you use the\end{document}

  11. \documentclass[options]{class} • First line of all LaTeX documents specifies the {type} of the document and the [stylesheet] used. • book • report • article • letter • Ready templates: IEEETrans, ACM, etc. • In general, required information is included in LaTeX commands in braces {}, while optional information is included in square brackets []. \documentclass[ieee]{article}

  12. \documentclass{article}

  13. \documentclass[twocolumn]{article}

  14. \documentclass{report}

  15. LaTeX Document Example (1) \documentclass{article} \begin{document} This is some sample text. \end{document}

  16. LaTeX Document Example (2) \documentclass{article} \begin{document} During the 1960s, many large software development efforts encountered severe difficulties. Software schedules were typically late, costs greatly exceeded budgets and the finished products were unreliable. \vspace{10 mm} \noindent People began to realize that software development was a far more complex activity than they had imagined. \end{document}

  17. LaTeX Document Example (2): result

  18. LaTeX Document Example (3) \documentclass{article} \begin{document} \title{Hello, World! In Latex} \author{Marc Corliss} \date{2/15/2006} \maketitle Hello, World!\\ \end{document} • To add a title to a document use \title and \maketitle • \title defines the title and \maketitle inserts it into the document • \maketitle must come after \begin{document} • \maketitle usually comes before any other text • \title must come before \maketitle • To add an author and date and use \author and \date

  19. LaTeX Document Example (3): result

  20. Abstracts • To create an abstract, place your text in an abstract environment, i.e., between \begin{abstract} and \end{abstract} commands. • The abstract should come immediately after your \maketitle command, but before any \tableofcontents command.

  21. Sections \section{Section Title} \subsection{Title} \subsubsection{Title}

  22. LaTeX Document Example (4) \documentclass{article} \begin{document} \title{Hello, World! In Latex} \author{Marc Corliss} \date{2/15/2006} \maketitle \begin{abstract} This is example 4. \end{abstract} \section{Hello, World!} Hello Everyone!\\ \end{document}

  23. LaTeX Document Example (4): result

  24. Spaces • Whitespace characters (e.g. blank, tab, single linebreak) are treated uniformly as “space” by LaTeX. • Several consecutive whitespace characters are treated as one “space”. • An empty line between two lines of text defines the end of a paragraph. • Several empty lines are treated in the same way as one empty line.

  25. Spaces \documentclass{article} \begin{document} It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. \end{document}. Editor view Document view

  26. Special Characters • The following symbols are reserved characters, that have a special meaning in LaTeX • $ & % # _ { } ~ ^ \ • Some of these characters can be used in your documents by adding a prefix backslash (escape character): • \$ \& \% \# \_ \{ \} • The other symbols (and many more!) can be printed with special commands in mathematical formulae.

  27. LaTeX Commands • LaTeX commands are case sensitive and start with a backslash \ \documentclass{article} \begin{document} This is \emph{emphasized} text. \end{document} Editor view Document view

  28. Comments • When LaTeX encounters a % character while processing an input file, it ignores the rest of the present line. • This is useful for adding notes to the input file, which will not show up in the printed version. \documentclass{article} \begin{document} This text is processed. % A comment isn’t \end{document} Editor view Document view

  29. Page Styles • LaTeX supports three predefined header/footer combinations. These are known as page styles. • The style parameter of the \pagestyle{style}command defines which one to use: • plain prints the page numbers on the bottom of the page in the middle of the footer (default page style) • headings prints the current chapter heading and the page number on each page header. • empty - both header and footer empty

  30. Hyphenation • There are four hyphens in LaTeX : • - (a single dash) is for hyphenating words. • -- (two dashes) is for ranges of numbers. • --- (three dashes) is for an honest-to-goodness dash between words. • $-$ is a minus sign in math mode.

  31. Hyphenation \documentclass{article} \begin{document} My cousin-in-law lived in Germany in 1995--2006; he speaks French---really, he does. His favorite number is $-2$. \end{document} Editor view Document view

  32. The LaTeX Logo • You can typeset the LATEX logo with the \LaTeX command. • As with most commands, it consumes any space behind it, so if it isn't at the end of a sentence, use \LaTeX\ instead.

  33. Appearance of Words • \underline{phrase} to underline a phrase, • \textbf{phrase} to print a phrase in boldface, and • \emph{phrase} to italicize a phrase.

  34. Centering Text • By default, LaTeX will start all text at the left margin. • If you want to center a title, a table, etc., surround what you want centered with the commands: \begin{center} and \end{center}.

  35. LaTeX Example (5) \documentclass{article} \begin{document} \title{\LaTeX\ 1, 2, 3} \author{Liguo Yu} \maketitle \section{Introduction} \begin{center} This is an intruduction! \end{center} \section{Conclusion} Thanks for reading this \textbf{article}. \end{document}

  36. LaTex Example (5): Result

  37. Bulleted Lists • To create a bulleted list, surround the information with a \begin{itemize} and an \end{itemize}, and begin each item with an \item. \documentclass{article} \begin{document} \begin{itemize} \item A bulleted item. \item Another bulleted item. \begin{itemize} \item A nested bulleted item. \end{itemize} \item You get the idea. \end{itemize} \end{document} Document view Editor view

  38. Numbered Lists • To create a numbered list, surround the information with a \begin{enumerate} and an \end{enumerate}, and begin each item with an \item. \documentclass{article} \begin{document} \begin{enumerate} \item A numbered item. \item Another numbered item. \item You get the idea. \end{enumerate} \end{document} Document view Editor view

  39. Typesetting Mathematics • LaTeX has a Math mode for typesetting mathematics. • Within a paragraph, math mode is entered between $ characters, or by using the \begin{math} and \end{math} commands \documentclass{article} \begin{document} Add a squared to b squared to find c squared, e.g. $a^2 + b^2 = c^2$. It’s as easy as that! \end{document} Editor view Document view

  40. Typesetting Mathematics Greek Symbols \alpha, \beta, \gamma Superscript, Subscript x^yx_y x_y^z Calculus \int_0^\infty \int{\int} \frac{\partial u}{\partial x}

  41. Typesetting Mathematics x = \frac{-b \pm\sqrt{b^2-4ac}} {2a}

  42. Figures \begin{figure} \includegraphics{sample.jpg} \caption{A sample figure.} \end{figure}

  43. Example \documentclass{article} \usepackage[pdftex]{graphicx} \begin{document} \begin{figure} \centering \includegraphics{Figure1.jpg} \caption{Depiction of the production of kernel-based software} \end{figure} \end{document} Compile: pdflatexfile_name

  44. Result

  45. Tabular Two Columns • Columns • \begin{tabular}{|…|…|} • \end{tabular} • Rows • & - Split text into columns • \\ - End a row • \hline - Draw line under row l = automatically adjust size, left justify r = automatically adjust size, right justify p = set size e.g p{4.7cm} c = centre text

  46. Example of table \documentclass{article} \begin{document} \begin{tabular}{|l|r|c|} \hline Date & Price & Size \\ \hline Yesterday & 5 & Big \\ \hline Today & 3 & Small \\ \hline \end{tabular} \end{document} Editor view Document view

  47. Bibliographies • Articles can be referred to in the text using the \cite command • The details of the cited articles are stored in BibTeX format, in a “.bib” file. • BibTeX resolves the citations in the LaTeX file and generates the required bibliography

  48. Bibliographies • Example entries from test.bib file: @book{AhR1975, author = {N. Ahmed and K. Rao}, title = {Digital signal processing}, publisher = {Springer-Verlag}, year = {1975}, address = {New York}, } @inproceedings{Aus1989, author = {James Austin and A. Phantom and B. Nom}, title = {High Speed Neural Networks},booktitle = {IEE Image Processing and Applications}, year = {1989}, pages = {28--32},}

  49. test.tex file \documentclass[12]{article} \begin{document} \title{Work Study 1, 2, 3} \author{Liguo Yu} \date{\today} \maketitle \section{Introduction} This is an intruduction! \section{Result} By far the most commonly used feature is presented by \cite{Aus1989}and \cite{Ahr1975}. \section{Conclusion} Thanks for reading this article. \bibliographystyle{abbrv} \bibliography{test} \end{document}

  50. Compile LaTeX • We need to compile .tex and .bib separately and combine the output together to generate a PDF file >latex test (compile .tex file) >bibtex test (compile .bib file) >pdflatex test (geberate .pdf file) • Might need to run several rounds to successfully combine them

More Related