├── h.pdf ├── sigmoid.pdf ├── latex101.pdf ├── table97-a4symbols.png ├── Makefile ├── README.md ├── unicode-eg.tex ├── LICENSE ├── .gitignore └── latex101.tex /h.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sje30/latex101/HEAD/h.pdf -------------------------------------------------------------------------------- /sigmoid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sje30/latex101/HEAD/sigmoid.pdf -------------------------------------------------------------------------------- /latex101.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sje30/latex101/HEAD/latex101.pdf -------------------------------------------------------------------------------- /table97-a4symbols.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sje30/latex101/HEAD/table97-a4symbols.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: latex101.pdf 2 | 3 | latex101.pdf: latex101.tex 4 | pdflatex -interaction=nonstopmode latex101 5 | 6 | ## intro-tex.pdf is a formatted version of the .tex input file. 7 | latex101-tex.pdf: latex101.tex 8 | a2ps $^ -o - | ps2pdf - > $@ 9 | 10 | %-4up.pdf: %.pdf 11 | pdfnup -q --nup 2x2 --suffix '4up' $< 12 | 13 | h.pdf: latex101.tex 14 | pdflatex -jobname='h' -interaction=nonstopmode \ 15 | '\newcommand{\handouts}{true}\input{latex101.tex}' 16 | 17 | unicode-eg-crop.pdf: unicode-eg.tex 18 | xelatex unicode-eg.tex 19 | pdfcrop unicode-eg.pdf 20 | 21 | 22 | .PHONY: clean 23 | 24 | clean: 25 | rm -fr latex101.pdf 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # latex101 2 | 3 | These are the [slides](latex101.pdf) for a 1 hour lecture introducing LaTeX to 4 | undergraduates in maths and postgraduates in computational biology. 5 | 6 | The slides are also available in [handout](h.pdf) format. 7 | 8 | ## 2020 lecture 9 | 10 | 11 | 12 | 13 | 14 | 15 | In 2020 this lecture will be given online. 16 | 17 | 18 | 19 | The complementary template report is available at https://github.com/sje30/texintro/blob/master/intro.pdf 20 | 21 | 22 | -------------------------------------------------------------------------------- /unicode-eg.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt]{article} 2 | \usepackage{unicode-math} 3 | 4 | \setmainfont[Ligatures=TeX]{TeX Gyre Pagella} 5 | %%\setmathfont{TeX Gyre Pagella Math} 6 | \setmathfont{texgyrepagella-math.otf} 7 | \begin{document} 8 | 9 | \thispagestyle{empty} 10 | 11 | The xelatex engine allows for Unicode to be entererd directly into the 12 | source file. This may make your source file more readable. 13 | 14 | This is some math text entered with math in the source: 15 | \[ 16 | ∀X [ ∅ ∉ X ⇒ ∃f:X ⟶ ⋃ X\ ∀A ∈ X (f(A) ∈ A ) ]\] 17 | 18 | This is some math text entered with regular markup 19 | 20 | \[ 21 | \forall X [\emptyset \not\in X \Rightarrow \exists f:X \rightarrow \bigcup X\ 22 | \forall A \in X (f(A) \in A ) ]\] 23 | 24 | $∫_ξ^θ f(x)\,dx$ 25 | 26 | 27 | %% Examples taken from 28 | %% https://tex.stackexchange.com/questions/118244/what-is-the-difference-between-unicode-math-and-mathspec 29 | 30 | \end{document} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Stephen Eglen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Core latex/pdflatex auxiliary files: 2 | *.aux 3 | *.lof 4 | *.log 5 | *.lot 6 | *.fls 7 | *.out 8 | *.toc 9 | *.fmt 10 | *.fot 11 | *.cb 12 | *.cb2 13 | 14 | ## Intermediate documents: 15 | *.dvi 16 | *-converted-to.* 17 | # these rules might exclude image files for figures etc. 18 | # *.ps 19 | # *.eps 20 | # *.pdf 21 | 22 | ## Bibliography auxiliary files (bibtex/biblatex/biber): 23 | *.bbl 24 | *.bcf 25 | *.blg 26 | *-blx.aux 27 | *-blx.bib 28 | *.brf 29 | *.run.xml 30 | 31 | ## Build tool auxiliary files: 32 | *.fdb_latexmk 33 | *.synctex 34 | *.synctex.gz 35 | *.synctex.gz(busy) 36 | *.pdfsync 37 | 38 | ## Auxiliary and intermediate files from other packages: 39 | # algorithms 40 | *.alg 41 | *.loa 42 | 43 | # achemso 44 | acs-*.bib 45 | 46 | # amsthm 47 | *.thm 48 | 49 | # beamer 50 | *.nav 51 | *.snm 52 | *.vrb 53 | 54 | # cprotect 55 | *.cpt 56 | 57 | # fixme 58 | *.lox 59 | 60 | #(r)(e)ledmac/(r)(e)ledpar 61 | *.end 62 | *.?end 63 | *.[1-9] 64 | *.[1-9][0-9] 65 | *.[1-9][0-9][0-9] 66 | *.[1-9]R 67 | *.[1-9][0-9]R 68 | *.[1-9][0-9][0-9]R 69 | *.eledsec[1-9] 70 | *.eledsec[1-9]R 71 | *.eledsec[1-9][0-9] 72 | *.eledsec[1-9][0-9]R 73 | *.eledsec[1-9][0-9][0-9] 74 | *.eledsec[1-9][0-9][0-9]R 75 | 76 | # glossaries 77 | *.acn 78 | *.acr 79 | *.glg 80 | *.glo 81 | *.gls 82 | *.glsdefs 83 | 84 | # gnuplottex 85 | *-gnuplottex-* 86 | 87 | # hyperref 88 | *.brf 89 | 90 | # knitr 91 | *-concordance.tex 92 | # TODO Comment the next line if you want to keep your tikz graphics files 93 | *.tikz 94 | *-tikzDictionary 95 | 96 | # listings 97 | *.lol 98 | 99 | # makeidx 100 | *.idx 101 | *.ilg 102 | *.ind 103 | *.ist 104 | 105 | # minitoc 106 | *.maf 107 | *.mlf 108 | *.mlt 109 | *.mtc 110 | *.mtc[0-9] 111 | *.mtc[1-9][0-9] 112 | 113 | # minted 114 | _minted* 115 | *.pyg 116 | 117 | # morewrites 118 | *.mw 119 | 120 | # mylatexformat 121 | *.fmt 122 | 123 | # nomencl 124 | *.nlo 125 | 126 | # sagetex 127 | *.sagetex.sage 128 | *.sagetex.py 129 | *.sagetex.scmd 130 | 131 | # sympy 132 | *.sout 133 | *.sympy 134 | sympy-plots-for-*.tex/ 135 | 136 | # pdfcomment 137 | *.upa 138 | *.upb 139 | 140 | # pythontex 141 | *.pytxcode 142 | pythontex-files-*/ 143 | 144 | # thmtools 145 | *.loe 146 | 147 | # TikZ & PGF 148 | *.dpth 149 | *.md5 150 | *.auxlock 151 | 152 | # todonotes 153 | *.tdo 154 | 155 | # xindy 156 | *.xdy 157 | 158 | # xypic precompiled matrices 159 | *.xyc 160 | 161 | # endfloat 162 | *.ttt 163 | *.fff 164 | 165 | # Latexian 166 | TSWLatexianTemp* 167 | 168 | ## Editors: 169 | # WinEdt 170 | *.bak 171 | *.sav 172 | 173 | # Texpad 174 | .texpadtmp 175 | 176 | # Kile 177 | *.backup 178 | 179 | # KBibTeX 180 | *~[0-9]* 181 | -------------------------------------------------------------------------------- /latex101.tex: -------------------------------------------------------------------------------- 1 | \documentclass[]{beamer} 2 | %%\documentclass[notes]{beamer} 3 | \usepackage{etex} 4 | \usepackage[default]{sourcesanspro} 5 | 6 | 7 | %% Default will be false for \handouts; it can be set to true within 8 | %% the Makefile. 9 | 10 | \newcommand{\adv}{{\tiny (Advanced)}} 11 | 12 | \usepackage{showexpl,xspace} 13 | \usepackage{ifthen} 14 | \usepackage{amsmath} 15 | \usepackage{xspace} 16 | \usepackage{xskak} 17 | 18 | \providecommand*{\latex}{\LaTeX\xspace} 19 | 20 | \providecommand*{\handouts}{false} 21 | 22 | \ifthenelse{\equal{\handouts}{true}} 23 | {\usepackage{pgfpages} 24 | \pgfpagesuselayout{4 on 1}[a4paper,landscape]} 25 | {} 26 | %% Handling handouts: end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | 28 | 29 | 30 | 31 | 32 | %% \newcommand{\pauseb}{} 33 | 34 | %% fragwidth will measure the width of the text, and then we use 35 | %% it for the width of the textblock. 36 | \newdimen{\fragwidth} 37 | 38 | \newcommand{\mybottomleft}[1]{ 39 | \settowidth{\fragwidth}{#1} 40 | \begin{textblock*}{\fragwidth}[0,0](2mm,90mm) %% {width}(horiz, vert) 41 | #1 42 | \end{textblock*} 43 | } 44 | 45 | \newcommand{\mybottomright}[1]{ 46 | \settowidth{\fragwidth}{#1} 47 | \begin{textblock*}{\fragwidth}[1,0](126mm,90mm) %% {width}(horiz, vert) 48 | #1 49 | \end{textblock*} 50 | } 51 | 52 | \usepackage{graphicx} 53 | 54 | \def\0{\hbox{\phantom{\footnotesize\rm 0}}} 55 | 56 | %% Seek help from beamer crowd about this? 57 | \makeatletter 58 | \def\DIfF^#1{% 59 | \mathop{\mathrm{\mathstrut \text{d}}}% 60 | \nolimits^{#1}\gobblespace} 61 | \makeatother 62 | 63 | 64 | %%http://tex.stackexchange.com/questions/249437/redefine-latex-command 65 | \makeatletter 66 | \renewcommand{\LaTeX}{L\kern -.20em{\sbox \z@ T\vbox to\ht \z@ {\hbox {\check@mathfonts \fontsize \sf@size \z@ \math@fontsfalse \selectfont A}\vss }}\kern -.10em\TeX} 67 | \makeatother 68 | 69 | %% This snippet is from the TeX faq and allows us to use \maxwidth 70 | %% for the max size of an image. 71 | \makeatletter 72 | \def\maxwidth{% 73 | \ifdim\Gin@nat@width>\linewidth 74 | \linewidth 75 | \else 76 | \Gin@nat@width 77 | \fi 78 | } 79 | \makeatother 80 | \usepackage[overlay]{textpos} 81 | 82 | \mode 83 | { 84 | \setbeamersize{text margin left=0.25cm} 85 | \setbeamersize{text margin right=0.25cm} 86 | 87 | \beamertemplatedotitem 88 | 89 | \beamertemplateheadempty %% Remove headline (at top of frame) 90 | %% \beamertemplatefootempty %% Remove headline (at top of frame) 91 | %% \beamertemplatefootpagenumber %% page number only in footer. 92 | %% Remove navigation icons. 93 | \setbeamertemplate{navigation symbols}{} 94 | 95 | %% Show start of every lecture. Not available in article. 96 | \AtBeginLecture{\frame{\Large Lecture \insertlecture}} 97 | } 98 | 99 | 100 | 101 | 102 | \title{\LaTeX\ 101} 103 | \author{Stephen J. Eglen} 104 | 105 | 106 | \institute{Cambridge Computational Biology Institute\\ 107 | Department of Applied Mathematics and Theoretical Physics\\ 108 | University of Cambridge\\ 109 | \url{http://github.com/sje30/latex101} 110 | } 111 | 112 | \date{October 2020} 113 | 114 | \begin{document} 115 | 116 | \begin{frame} 117 | \titlepage 118 | \end{frame} 119 | 120 | \begin{frame} 121 | \frametitle{What is \LaTeX?} 122 | \begin{itemize} 123 | \item Typesetting, not WYSIWYG. 124 | \item Given a source file (file.tex) you \textbf{compile} your document (file.pdf). 125 | \item Heavily used by mathematicians/scientists/publishers for 126 | formatting papers/books. 127 | \item Logical markup of your document (like HTML) rather than 128 | specifying exactly how you want it look. 129 | \item Use Word (or program of your choice) if you want to. 130 | 131 | \item These slides are written in \latex using the ``beamer'' package. 132 | 133 | \item You can typeset music, wiring diagrams, chess \ldots 134 | 135 | \end{itemize} 136 | \end{frame} 137 | 138 | \begin{frame}[fragile] 139 | %% \frametitle{Chess} 140 | %% This uses the xskak package. "skak" is "chess" in Danish. 141 | %% Example taken from http://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/xskak/xskak.pdf 142 | \begin{LTXexample}[pos=b,rframe={}] 143 | \newchessgame % from the xskak package 144 | \mainline{1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6} 145 | \chessboard 146 | \end{LTXexample} 147 | \end{frame} 148 | 149 | 150 | \begin{frame}[fragile] 151 | \frametitle{``Hello world'' example} 152 | 153 | \section*{hi there} 154 | \begin{LTXexample}[pos=b,rframe={}] 155 | \documentclass{article} 156 | \begin{document} 157 | Hello world. Welcome to \LaTeX. 158 | \end{document} 159 | \end{LTXexample} 160 | %% Complicated begin/end documents don't work in beamer. 161 | %% http://tex.stackexchange.com/questions/6006/how-to-use-showexpl-with-an-external-class 162 | \end{frame} 163 | 164 | 165 | \begin{frame}[fragile] 166 | \frametitle{Another example {\tiny (Taken from \url{showexpl-test.tex})}} 167 | \begin{LTXexample}[pos=b,wide,width=.65,preset=\LARGE,rframe={}] 168 | \documentclass[a4paper,twoside]{article} 169 | \begin{document} 170 | \begin{equation} 171 | \sigma(t)=\frac{1}{\sqrt{2\pi}} 172 | \int^t_0 e^{-x^2/2} dx 173 | \end{equation} 174 | \end{document} 175 | \end{LTXexample} 176 | 177 | \end{frame} 178 | 179 | \begin{frame} 180 | \frametitle{Getting started} 181 | 182 | \begin{itemize} 183 | \item \latex is free to download. \url{https://www.latex-tutorial.com/installation/} 184 | 185 | \item Can use it from the command line. 186 | 187 | \item Lots of editors/GUIs available. 188 | 189 | \item I suggest trying \textit{texstudio} or \textit{texmaker}. 190 | They both handle all the compilation steps for you and provides 191 | easy way of forward/inverse searching (Ctrl + left mouse button). 192 | 193 | \item \url{http://www.lyx.org} = latex engine + WYSIWYG interface. 194 | \end{itemize} 195 | 196 | \end{frame} 197 | 198 | \begin{frame}[fragile] 199 | \frametitle{Welcome to the 21st century} 200 | 201 | \begin{enumerate} 202 | \item Many \latex guides describe how you can create .dvi files and .ps 203 | (postscript) files. 204 | \item Ignore that; we typically create .pdf files now, via 205 | 'pdflatex'. 206 | \item Create your figures in .pdf or .eps wherever you can, else 207 | png/jpg. 208 | 209 | \item Matlab users: .eps files have tight bounding boxes, whereas 210 | pdf files do not. However, pdflatex will silently convert \url{sin.eps} to 211 | \url{sin-eps-converted-to.pdf} for you: 212 | \begin{verbatim} 213 | \fbox{\includegraphics[width=6cm]{sin.eps}} 214 | \end{verbatim} 215 | \end{enumerate} 216 | \end{frame} 217 | 218 | 219 | \begin{frame} 220 | \frametitle{Online tools (good for collaboration)} 221 | 222 | \begin{itemize} 223 | \item \url{www.overleaf.com} (Demo) 224 | \item \url{www.authorea.com} 225 | \end{itemize} 226 | \end{frame} 227 | 228 | \begin{frame}[fragile] 229 | \frametitle{\latex syntax - commands} 230 | 231 | \begin{itemize} 232 | \item \latex commands start with backslash and are case-sensitive: 233 | 234 | \begin{LTXexample}[pos=b] 235 | The \large cat \LARGE sat on \Huge the \normalsize mat 236 | \end{LTXexample} 237 | 238 | \item Commands can take compulsory \{ \ldots \} and optional [ 239 | \ldots ] arguments. 240 | \begin{LTXexample}[pos=b] 241 | A \rule{10mm}{3mm} B \rule[-1mm]{10mm}{3mm} 242 | \end{LTXexample} 243 | \item You can sometimes drop \{ and \}: 244 | \begin{LTXexample}[pos=b] 245 | e.g. if superscript is one character: compare $x^3$ with 246 | $x^{19}$ and with $x^19$. 247 | 248 | \end{LTXexample} 249 | \end{itemize} 250 | \end{frame} 251 | 252 | 253 | \begin{frame}[fragile] 254 | \frametitle{Special characters} 255 | 256 | Some characters are commands. To type these characters, you normally 257 | escape them: 258 | \begin{LTXexample}[pos=b] 259 | I got a 30\% discount, saving me a few \$\$\$ \ldots 260 | \end{LTXexample} 261 | 262 | The most common characters that need escaping are: 263 | \begin{center} 264 | \verb+\ $ ^ _ % # & ~ { } + 265 | \end{center} 266 | 267 | \end{frame} 268 | 269 | \begin{frame}[fragile] 270 | \frametitle{Space} 271 | 272 | 273 | \begin{LTXexample}[pos=b] 274 | Multiple spaces between words are treated as 275 | one space. 276 | 277 | Blank lines denote 278 | paragraph separators. 279 | 280 | Use a non-breaking space, like 3~mm, to prevent line breaks. Even 281 | better for separating numbers from units, try a small non-breaking 282 | space, e.g. 3\,mm. 283 | \end{LTXexample} 284 | \end{frame} 285 | 286 | 287 | 288 | 289 | 290 | \begin{frame}[fragile] 291 | \frametitle{Environments} 292 | 293 | An environment is a block of latex code to provide some 294 | functionality. They can be nested. 295 | \begin{LTXexample}[pos=r] 296 | \textbf{Top TV programmes}: 297 | \begin{enumerate} 298 | \item Homeland 299 | \item The West Wing 300 | \begin{itemize} 301 | \item Series 1 302 | \item (Not series 3) 303 | \end{itemize} 304 | \item 24 305 | \end{enumerate} 306 | \end{LTXexample} 307 | \end{frame} 308 | 309 | 310 | 311 | \begin{frame}[fragile] 312 | \frametitle{Typesetting math} 313 | 314 | \begin{enumerate} 315 | \item \latex normally is in text mode. You must switch to math mode 316 | using \$ to get into and out of math. 317 | \begin{LTXexample}[pos=b] 318 | This equation $x^2 + y^2 = z^2$ is in-line; compare with: 319 | \begin{align} 320 | I_1 &= \int_0^{2 \pi} \sin (x^2) dx \nonumber \\ 321 | \text{but}\, I_2 &= \int_0^{2 \pi} \cos (x^2) dx \label{key} 322 | \end{align} 323 | The dx in Equation 2 needs fixing later \ldots 324 | \end{LTXexample} 325 | 326 | \end{enumerate} 327 | \end{frame} 328 | 329 | 330 | \begin{frame} 331 | \frametitle{amsmath -- AMS mathematical facilities for \latex} 332 | 333 | \url{http://mirrors.ctan.org/macros/latex/required/amslatex/math/amsldoc.pdf} 334 | 335 | Lots of good examples for formatting maths. See the examples in: 336 | 337 | \url{http://mirrors.ctan.org/macros/latex/required/amslatex/math/testmath.pdf} 338 | 339 | \vspace*{1cm} 340 | 341 | This is an example of a package that has been contributed to 342 | \latex. These packages are available on Comprehensive TeX Archive 343 | Network (CTAN). Most of them are downloaded for you when installed \latex. 344 | \end{frame} 345 | \begin{frame} 346 | \frametitle{Universe of mathematics symbols and operators} 347 | 348 | 349 | \url{http://mirror.ox.ac.uk/sites/ctan.org/info/symbols/comprehensive/symbols-a4.pdf} 350 | 351 | contains $\sim$6000 symbols and \latex commands to 352 | generate them. e.g. see Table 97 for inequalities: 353 | 354 | \centerline{\includegraphics[width=9cm]{table97-a4symbols.png}} 355 | 356 | 357 | \end{frame} 358 | 359 | \begin{frame} 360 | \frametitle{Finding maths operators the ``modern'' way} 361 | 362 | \begin{itemize} 363 | \item Draw some equations and it will try to render it in latex or 364 | mathml: 365 | 366 | Wolfram: graph an equation, with latex output. 367 | \url{http://webdemo.myscript.com/\#/demo/equation} 368 | %% needed to escape hash 369 | 370 | \item \url{http://detexify.kirelabs.org/classify.html} 371 | 372 | 373 | 374 | \end{itemize} 375 | 376 | 377 | 378 | \end{frame} 379 | 380 | 381 | \begin{frame}[fragile] 382 | \frametitle{Defining your own commands} 383 | 384 | 385 | \begin{LTXexample}[pos=b] 386 | \newcommand{\betaIIKO} 387 | {\ensuremath{\beta\mathit{2}^{-/-}}\xspace} 388 | The \betaIIKO mouse is widely studied \ldots 389 | the \betaIIKO command is easier for me 390 | to type than the whole expansion. 391 | 392 | \newcommand{\nnn}[1]{\ensuremath{#1^{#1^{#1}}}} 393 | Or we can compare \nnn{3} with \nnn{16}. 394 | \end{LTXexample} 395 | 396 | \textit{Typesetting mathematics for science} has many hints for 397 | getting things ``just right'', e.g. the differential operator, partial, total derivatives: 398 | \url{http://www.tug.org/TUGboat/Articles/tb18-1/tb54becc.pdf} 399 | 400 | 401 | \end{frame} 402 | 403 | 404 | \begin{frame}[fragile] 405 | \frametitle{Bibliography / citations} 406 | 407 | Entries like the following are stored in a bibliography file: 408 | 409 | \begin{verbatim} 410 | @article{ihaka1996, 411 | author = {R. Ihaka and R. Gentleman}, 412 | title = {R: A Language for Data Analysis and Graphics}, 413 | journal = {Journal of Computational . . . Statistics}, 414 | year = 1996, 415 | volume = 5, 416 | pages = {299--314} 417 | } 418 | \end{verbatim} 419 | 420 | which you can then cite using e.g. 421 | \begin{verbatim} 422 | We used the R programming environment \cite{ihaka1996} 423 | for our analysis. 424 | \end{verbatim} 425 | 426 | To create: 427 | 428 | 429 | \begin{verbatim} 430 | We used the R programming environment (Ihaka and Gentleman, 431 | 1996) for our analysis. 432 | \end{verbatim} 433 | 434 | and references at end. See \url{texintro/intro.tex} 435 | for more info. 436 | 437 | 438 | \end{frame} 439 | 440 | \begin{frame} 441 | \frametitle{Creating a bibliography} 442 | 443 | \begin{itemize} 444 | \item Create it by hand. Slow, tedious, and error-prone. 445 | \item Grab them from Google scholar, e.g. 446 | \url{http://scholar.google.co.uk/scholar?q=ihaka+gentleman}. The 447 | cite link takes you to the formats for citing (you may need to 448 | configure google scholar). 449 | \item zotero/paperpile/mendeley all generate good bibtex 450 | entries. 451 | 452 | \end{itemize} 453 | 454 | 455 | \end{frame} 456 | 457 | 458 | 459 | 460 | \begin{frame}[fragile] 461 | \frametitle{Preamble} 462 | 463 | \begin{enumerate} 464 | \item Everything before the \verb+begin{document}+ is the preamble. 465 | \item Use it to set up document, load packages. My favourite 466 | packages: 467 | 468 | 469 | \begin{verbatim} 470 | \usepackage{graphicx} % Including graphics. 471 | \usepackage{url} % active URLs. 472 | \usepackage[a4paper,margin=2cm]{geometry} 473 | \usepackage{mathpazo} % or mathptmx 474 | \usepackage{amsmath} % AMS Maths goodies 475 | \end{verbatim} 476 | \end{enumerate} 477 | \end{frame} 478 | 479 | 480 | \begin{frame} 481 | \frametitle{Your choice of fonts} 482 | 483 | Choose a font that has good support for both math and text modes: 484 | 485 | \begin{enumerate} 486 | \item Do nothing. Stick with Donald Knuth's \textit{Computer Modern}. 487 | \item I prefer mathpazo (Palatino) or mathptmx (Times). 488 | \item Explore the free guide \url{http://mirrors.ctan.org/info/Free_Math_Font_Survey/en/survey.html} 489 | \end{enumerate} 490 | \end{frame} 491 | 492 | 493 | \begin{frame} 494 | \frametitle{Floats: tables and figures} 495 | 496 | \begin{itemize} 497 | \item Floats are objects (tables, figures) that move in your 498 | document; \latex will move them to somewhere it thinks sensible. 499 | \item If you don't like where it put a float, relax. You can give 500 | it hints, but normally it does a good job. 501 | 502 | 503 | \item This is the \latex philosophy in general -- let it worry about 504 | layout so that you worry about content. 505 | \item You can then refer to figures/tables by labels. 506 | \end{itemize} 507 | \end{frame} 508 | 509 | \begin{frame}[fragile] 510 | \frametitle{Tables} 511 | 512 | \begin{LTXexample}[pos=b,rframe={}] 513 | \begin{table} 514 | \centering 515 | \begin{tabular}{|l|rr|} \hline 516 | year & min temp (C) & max temp (C)\\ \hline 517 | 1970 & -5 & 35\\ 518 | 1980 & -3 & 30\\ 519 | 1985 & -2 & 32\\ \hline 520 | \end{tabular} 521 | \caption{Fictional min/max temperatures.} \label{tab:simple} 522 | \end{table} 523 | \end{LTXexample} 524 | \end{frame} 525 | 526 | 527 | \begin{frame}[fragile] 528 | \frametitle{Labels and references} 529 | \label{labels} 530 | \begin{enumerate} 531 | \item For complex documents, rather than writing ``Table 3'', it is 532 | better to give the Table a label using \verb+\label{tab:simple}+, 533 | and then refer to that label, using e.g. 534 | \verb+See Table~\ref{tab:simple}+. 535 | 536 | \item You can also refer to figures, equations, sections in a 537 | similar way. 538 | 539 | \item To refer to pages you can do: 540 | \begin{LTXexample}[pos=b] 541 | This is on page \pageref{labels}. 542 | \end{LTXexample} 543 | \end{enumerate} 544 | \end{frame} 545 | 546 | \begin{frame}[fragile] 547 | \frametitle{Figures} 548 | 549 | \begin{LTXexample}[pos=b,rframe={}] 550 | \begin{figure} 551 | \centering 552 | \fbox{\includegraphics[width=4cm]{sigmoid}} 553 | \caption{Example of a sigmoidal curve.} 554 | \label{fig:example} 555 | \end{figure} 556 | \end{LTXexample} 557 | 558 | Looks for file in current directory (or you can keep a path of figures). 559 | \end{frame} 560 | 561 | 562 | 563 | \begin{frame} 564 | \frametitle{Advanced topics} 565 | 566 | \begin{description} 567 | 568 | \item[mathml] \url{http://docs.mathjax.org/en/latest/tex.html} 569 | latex in your web pages is converted to mathml, and then rendered. 570 | \item[lualatex] Embedded programming language (LUA) within latex. 571 | \item[Reproducible research] 572 | \url{https://github.com/sje30/waverepo/blob/master/paper/waverepo_paper.Rnw} 573 | \url{http://www.gigasciencejournal.com/content/3/1/3} 574 | 575 | \item[markdown] If latex looks too cumbersome/heavyweight, write in 576 | markdown, which can then be converted to .tex (.pdf) or .html or 577 | .doc by \url{http://johnmacfarlane.net/pandoc/} 578 | 579 | \item[unicode] xelatex engine allows you to use unicode directly in 580 | source file, e.g. $\alpha$ rather than the command. See 581 | \url{https://github.com/sje30/latex101/blob/master/unicode-eg.tex} 582 | 583 | \end{description} 584 | 585 | \end{frame} 586 | 587 | 588 | \begin{frame} 589 | \frametitle{Getting help} 590 | \begin{enumerate} 591 | 592 | \item Work through Lamport's book slowly and surely. 593 | 594 | \item Google what you need to. Often you can find good answers on 595 | \url{http://tex.stackexchange.com/} 596 | 597 | \item Keep it simple for now! Focus on the content, not the form. 598 | 599 | \item \textit{The \latex companion} lists vast number of packages. 600 | \end{enumerate} 601 | \end{frame} 602 | 603 | 604 | \begin{frame} 605 | \frametitle{Further reading} 606 | A (not so) short introduction to LaTeX2e 607 | \url{https://www.ctan.org/tex-archive/info/lshort/english/?lang=en}. 608 | (about 133 pages). 609 | 610 | Lamport (1994) LaTeX: a Document Preparation System : User's Guide 611 | and Reference Manual. 612 | 613 | Kopka and Daly (2003) A Guide to LaTeX (Tools and Techniques for 614 | Computer Typesetting). 615 | 616 | Mittelbach et al. (2004.) The LaTeX Companion. 617 | 618 | 619 | \vspace*{3cm} 620 | 621 | \textbf{Acknowledgements} Thanks to Robert Stojnic and Markus Kuhn, who wrote 622 | similar lectures and shared material. 623 | 624 | \end{frame} 625 | 626 | 627 | \begin{frame} 628 | \frametitle{History of \TeX \xspace and \latex} 629 | 630 | \TeX\xspace was originally a six-month project in 1978 started by 631 | Donald Knuth, which took ten years: 632 | 633 | \url{http://www.ctan.org/ctan-portal/tex/} 634 | \end{frame} 635 | 636 | \begin{frame} 637 | \frametitle{Command line material \adv } 638 | 639 | If you run from the command line, you need to follow instructions on 640 | how often to re-rerun \latex to resolve references. 641 | 642 | latexmk, texi2pdf help with this problem. 643 | 644 | \end{frame} 645 | 646 | 647 | \end{document} 648 | 649 | % LocalWords: Eglen 650 | 651 | --------------------------------------------------------------------------------