Here Comes Number Two
Total Page:16
File Type:pdf, Size:1020Kb
LATEX Documents ALATEX source file is an ordinary text file with interspersed typography markup. It may be created with any text editor (Notepad, Textedit, A gedit, emacs, vim) or with a dedicated LATEX editor with syntax LTEX highlighting (Texstudio, Texmaker). This text file will then be processed by a T X engine: Leif Andersson E latex, pdflatex, lualatex, xelatex The result is a .pdf file, which may be printed or read on screen. The Environment A Short Document The most fundamental LATEX component is the Environment. Inside an environment the text gets a special layout and/or special commands are defined. \documentclass{article} \usepackage{fourier} This is a paragraph with some This is a paragraph with some \usepackage[swedish]{babel} surrounding text. \begin{document} surrounding text. \begin{itemize} H¨ar kommer texten till mitt banbrytande dokument. \item This is the first point. This is the first point. \end{document} \item And here comes number two. • And here comes number two. \begin{enumerate} • The part between \documentclass and \begin{document} is \item Multiple levels are possible 1. Multiple levels are possible called the preamble, and may contain definitions special to this \item They get automatically 2. They get automatically document. In particular it may call on packages with the indented and enumerated. indented and enumerated. \end{enumerate} \usepackage command. \item The last point The last point • There are also style options \end{itemize} We also have some text after the \documentclass[a4paper,12pt]{article} We also have some text after different items. the different items. Documentclasses Special Characters To get Write Used for A Standard LTEX: $ \$ Start and end of math article report book letter memoir beamer % \% Comment to end of line Journals and conferences often have their own classes. & \& Column separator \_ Math subscript Local classes # \# Parameter placeholder \{ Start group or parameter LTHtwocol LTHthesis LTHreport { \} End group or parameter } More classes will be created as needed. ˆ \textasciicircum Math superscript \textbackslash Command character \ Options for standard classes ~ \texttildelow Non-breaking space 10pt 11pt 12pt final a4paper The last three characters require \usepackage{textcomp}. For the last character \usepackage{url} is better. Miscellaneous Commands New Paragraph and Vertical Space Sectioning The command \par or an empty line ends a paragraph. Any text \chapter{...} \section{...} \subsection{...} starts a new paragraph. \subsubsection{...} To make a stretchable vertical space, use the commands \smallskip, \medskip, or \bigskip respectively. To make a fixed, Type Size possibly larger vertical space, use \vspace{55mm}. These commands should be used between paragraphs. \tiny \scriptsize \footnotesize \small \normalsize The paragraph indent and the spacing between paragraphs are \large \Large \LARGE \huge decided by the document class. Do not make local changes for each paragraph! Cross Reference Note! \label{key} Define the reference. One place. A Some LTEX tutorials claim that the command \\ ends a \ref{key} Use the reference. Many places. paragraph. This is WRONG! key is any user-defined string. To be safe, use only A..Za..z0..9 1 Multiple command forms Environments Many commands have multiple forms \begin{center}...\end{center} Centered lines, use \\ to separate Optional argument: ♠ \item[$\spadesuit$] \begin{quotation}...\end{quotation} Narrower than surrounding text Star-form: ♠ \section*{An Unnumbered Section} {itemize} and {enumerate} as described above. \begin{description}...\end{description} They may sometimes be combined. Labeled items. In the last three cases the item is started with an \item command. The meaning of star-forms and optional arguments vary from The description needs an argument: \item[keylabel]. command to command, but in practice this is not a problem. Grouping Type Styles 1 LAT X type style is specified by three components: shape, series, family. A pair of curly braces ... in the text delimit a LAT X group. Any E { } E change made to a property (size, font, width, etc.) is only valid inside Italic shape \textit{Italic shape} the group. Small Caps shape \textsc{Small Caps shape} Boldface series \textbf{Boldface series} Some people like {\footnotesize small text} and others Roman family \textrm{Roman family} {\Large tend to shout}. Back to normal size. Sans Serif family \textsf{Sans Serif family} Typewriter family \texttt{Typewriter family} Some people like small text and others tend to shout. Back to Bold italic text \textbf{\textit{Bold italic text}} normal size. Use \emph{...} to get emphasized text inside other text. A LATEX environment is an implicit group, so after \emph{...\emph{...}...} will work properly. \begin{center}\LARGE ...\end{center} the text size would be These commands work only in text mode. In math mode, use back to normal. \mathrm, \mathbf, \mathit etc. Type Style 2 Verbatim Each of the commands in the previous slide have a corresponding Short verbatim strings: \verb? any $ % & # characters? declaration. Result: any $ % & # characters. The special marker may be any nonalphabetic character. {\itshape Italic shape} {\scshape Small Caps shape} Longer verbatim text is created with the {verbatim} environment. {\bfseries Boldface series} \begin{verbatim} {\rmfamily Roman family} Text with & % # any characters $ \ } { {\sffamily Sans Serif family} except the special string {\ttfamily Typewriter family} \end{verbatim} The special string is \end{verbatim} The {\em ...} declaration corresponds to the \emph{...} command. Result: The old commands \it \bf \ss \tt should not be used. They may Text with & % # any characters $ \ } { except the special string not work in new versions of important classes. Floating Figures and Tables Inserting Graphics \begin{figure} \begin{table} The modern T X engines, typically , can directly process \centering \caption{.....}\label{taa} E pdflatex %insert the graphics here \centering graphics of type .pdf, .jpg, .png, and through auto-conversion .eps. \caption{.....}\label{faa} %tabular material here All known graphics-generating programs can export to one of these \end{figure} \end{table} formats. Makes a floating insert. Note different placement of . This is \caption \usepackage{graphicx} a tradition, not a technical requirement. Note also that the \label ... must come after the \caption. \begin{center} \includegraphics[width=80mm]{drawing} Both environments can take an optional argument specifying desired \end{center} position. Do not use this until the really final version of the document. ... In particular, do not use the [h] variant at all. Many other options are available. See the documentation for Do not confuse the {table} environment with the {tabular} Packages in ‘The Graphics Bundle’ ( ) environment described later. texdoc graphicx 2 The Tabular Environment Tabular with booktabs \usepackage{booktabs} \begin{tabular}{||l|c|r||} \hline \begin{tabular}{lcr} \textit{Name} & \textit{Place} & \textit{Weight}\\ \toprule \hline\hline \textit{Name} & \textit{Place} & \textit{Weight}\\ O. Olsson & Lund & 73 \\ \midrule F. Baby & Varying & 4 \\ O. Olsson & Lund & 73 \\ P. Persson & Tokholmen & 110 \\ F. Baby & Varying & 4 \\ \hline P. Persson & Tokholmen & 110 \\ \end{tabular} \bottomrule \end{tabular} Name Place Weight O. Olsson Lund 73 Name Place Weight F. Baby Varying 4 P. Persson Tokholmen 110 O. Olsson Lund 73 F. Baby Varying 4 For professional-looking tables, use the package booktabs. P. Persson Tokholmen 110 Mathematics Math environments 1 \begin{equation} a = b + c + d a = b + c + d (1) Inline math: \end{equation} This formula \( f(x) = xˆ2 \) is an example. \begin{multline} Will give: a+b+c+d+e+f+g+h\\ a + b + c + d + e + f + g + h 2 This formula f(x) = x is an example. =i+j+k+l+m+n\\ = i + j + k + l + m + n +o+p+q+r+s Example:\( \cos2\theta = \cosˆ2 \theta - \sinˆ2 \theta \) \end{multline} + o + p + q + r + s (2) Example: cos 2θ = cos2 θ sin2 θ − \begin{equation} The pair \( \) may also be written $ $. A matter of personal taste. \begin{split} A &= x + y \\ A = x + y Displayed Math usually needs the amsmath package: &= a + b + c = a + b + c (3) \usepackage{amsmath} in the preamble. \end{split} \end{equation} The forms {equation*} and {multline*} get no number. Math Environments 2 Math Environments 3 \begin{gather} \begin{equation} a_{1}=b_{1}+c_{1}\\ \begin{aligned} a_{2}=b_{2}+c_{2} a1 = b1 + c1 (4) a_{11}+b_{11}&=c_{11} & a_{12}&=c_{12}\\ a + b = c a = c -d_{2}+e_{2} a2 = b2 + c2 d2 + e2 (5) 11 11 11 12 12 − a_{21}&=b_{21}+c_{21} & (7) a21 = b21 + c21 a22 = b22 \end{gather} a_{22}&=b_{22} \begin{align} \end{aligned} a_1 &= b_1 + c_1 \notag\\ \end{equation} a_2 + b_2 &= c_2 + d_2 a1 = b1 + c1 \begin{equation} a + b = c + d + e (6) + e_2 2 2 2 2 2 \lvert x\rvert = \end{align} \begin{cases} x if x < 0 -x & \text{if } x < 0 \\ x = − (8) Do not use {eqnarray}! It works, but the result is ugly. | | x if x 0 x & \text{if } x\ge 0 ( ≥ Note that {align} uses only one & to the left of \end{cases} the alignment point. \end{equation} Matrices and Fractions Defining and Redefining Commands \begin{equation*} A = \begin{matrix} a_{11} & a_{12} \\ \newcommand{\DRC}{Defining and Redefining Commands} a a a_{21} & a_{22} A = 11 12 defines a new command \DRC that can be used as an abbreviation for a a \end{matrix} 21 22 ‘Defining and Redefining Commands’. \end{equation*} The new command must not exist previously. LATEX will a a a a {pmatrix} A = 11 12 {bmatrix} A = 11 12 refuse if it does. a21 a22! "a21 a22# Use \renewcommand... to redefine a command, if you really know what you are doing. The command must exist previously. LATEXwill 1 1 a=\frac{1}{x} + \frac{1}{y} a = + refuse if it does not. x y \newcommand\itbold[1]{\textit{\textbf{#1}}} 1 1 x + y defines a command with one parameter, to create b=\frac{\frac{1}{x}+\frac{1}{y}}{y-z} b = y z \itbold{bold italic} bold italic text.