LaTeX Information Literacy II EN(IL2) Course
Previous Lecture Saving plots to file Customizing plots Bar and pie charts
Today Introduction to Latex - Basic commands - Structure of the document - Mathematical expressions - Adding image Assignment 2 (and 3)
LaTeX A document preparation system developed by L. Lamport based on the TeX system created by D. Knuth. Will be written as "Latex" for simplicity. Takes a document created using the Latex markup language and converts into a format suitable for printing (typically PDF). Free software.
Latex (cont) Powerful support for mathematical formulas and diagrams, citations, cross-references, footnote, bibliographies, etc. Commonly used by publishers for preparation of books and academic journals. Flexible programming environment for creating new commands, environments, packages, etc.
Using Latex on your own computer Main Latex website: https://www.latex-project.org/ On MacOS: Install MacTeX: http://www.tug.org/mactex/ On Windows: Install MiKTeX: https://miktex.org/ Both distributions contain a complete system (including editor) Plenty of documentation online Easy to find help!
Advantage of Latex: Latex vs. Word - Portable: can be used on any computer - Stable: old documents can still be read - Standard in Academic world - Easier to use but only after some time Drawback of Latex: - Not WYSIWYG - Not so common outside of university - More difficult at the beginning
Latex General Idea Focus on the content Do not focus on the design Latex will choose automatically the best design How to use Latex: 1 Write a source file report.tex 2 Compile using Latex 2 Fix the errors and compile again 3 Check the result, typically report.pdf
Latex First Example \documentclass{article} \title{my first Latex document} \author{francois Bonnet} \begin{document} Always start with \documentclass[ ]{ } Latex commands use backslash: \commandname { } is for mandatory arguments [ ] is for optional arguments Use the \title{ }, \author{ }, and \date{ } to give title, author, and date \maketitle This is my first document written in Latex. It seems difficult but as we will see, it is not so difficult! \end{document} The main content of the document is between the \begin{document} and \end{document} commands The command \maketitle creates the top of the document
Latex In this room Use TeXShop to write Latex documents Compile using the Typeset button (or Cmd-T shortcut) Check/correct errors (if any)
Latex First Example \documentclass{article} \title{my first Latex document} \author{francois Bonnet} \begin{document} \maketitle This is my first document written in Latex. It seems complex but as we will see, it is not so difficult to write good documents using Latex! \end{document}
Latex Document structure... \begin{document} \section{how to use matplotlib} I describe here how to use matplotlib Use the commands \section{ } and \subsection{ }to structure your document. \section{how to use \LaTeX} I describe here how to use LaTeX. I will first explain history of Latex, then some basic commands, then... New paragraph starts after an empty line. Use an empty line to start a new paragraph. \subsection{history} Bla bla bla bla \subsection{basic commands} Bla bla bla bla Automatic numbering of sections and subsections Try subsubsection or \subsection{something else} \end{document} subsubsubsection or
Latex List... \begin{document} The itemize environment can be used to create a list of items. There are three main OS: \begin{itemize} \item macos To create numbered list, one should use the enumerate environment. \item Linux \item Windows \end{itemize} Try enumerate on your computer. Try nested lists on your computer. \end{document}
Latex Math expressions... \begin{document} It is very easy to write ``complex'' mathematical expressions: \begin{itemize} \item $\alpha$, $\beta$, $\gamma$, $\Gamma$, \ldots \item $\sqrt{256} = 16$ \item $x_1 + x_2 + x_3$ \item $(x+y)(x-y) = x^2 - y^2$ \end{itemize} \[ \sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6} \] \end{document} Inline mathematical expression appears between $...$ Display mode is activated using \[ \] and should be used for more complex formulas Use the `` and '' for quotes. Do not use the (double quotation mark) Note also the \ldots command that produces
\documentclass{article} Latex Insert images \usepackage{graphicx}... \begin{document} Use the graphicx package. Need to add it in the preamble with \usepackage{graphicx} \begin{figure} \centering \includegraphics[width=6cm]{figure4.pdf} \caption{a simple curve} \end{figure} \begin{figure} Use the figure environment to insert figures in the document. Specify the size of the figure with the width or height. \centering \includegraphics[width=\textwidth]{figure4.png} \caption{the same curve but larger and from a.png file} \end{figure} Use width=\textwidth to specify the full textwidth. \end{document}
Assignment 2 Create a Latex document assign2.tex that contains (at least): - A title and your name (as author) - Some short text (just a few lines) - The mathematical expression on the right: (Attention to parenthesis, look for help online) - One picture (for example, the one from Assignment 1) Typeset the file assign2.tex to create assign2.pdf Compress assign2.tex, the picture, and assign2.pdf into assign2.zip Submit via OCW-i the compressed file before July 10.
Assignment 3 Write a short document (2-5 pages) in Latex You can choose the topic: About your country, about sport, about videogame, about music, It should contains at least three graphs (made with matplotlib) of at least two different types (line, bar, pie, histogram, ) Deadline probably around end of July Do not wait for the last minute to start it!
Next time Other documentclass Some packages (and CTAN) Labels and references Bibliography and citations Table Japanese characters