LaTeX:

Doing it right for your thesis

Peter W. Smith

Follow along: https://pwsmith.github.io/reveal.js/latex_tutorial.html

Writing your PhD

Step one

Sit down to write.

Step two

???

Step three

Get PhD.

Source.

Using the right editor

Why?

  • The right editor can make a big difference.
  • A good editor will:
    • enable code snippets
    • have bibliography integration
    • let you compile LaTeX directly
    • help you manage your project
    • save you a lot of typing

Why?

  • An excellent text editor will:
    • be easily customisable
    • work cross platform
    • have direct git integration
    • do half the work for you

Which editor?

  • Often users will stick with the editor that comes with the LaTeX installation.
    • = TexShop
    • = Texworks
    • = Various
  • Often they are not the most sophisticated editors.
  • Advanced features may be difficult to configure.

Which editor?

  • In my experience, the following are the best editors.
  • None are LaTeX specific, but for software development.
  • All (except Sublime) are open source.
  • Good: they are more advanced, and have bigger communities working on them.
  • Bad: they come with bigger installations and use more system resources.

Atom

Atom

  • Highly Customisable
  • Excellent LaTeX integration
    (latextools package)
  • Direct git integration
  • Excellent unicode insertion.
  • Occasional difficulties with large files.
  • Smaller community compared to Sublime and VSCode
hello

Sublime Text

  • Similar to Atom, but proprietary (i.e. not open source)
  • Not free, but kinda free.

Sublime Text

  • Excellent LaTeX integration (also latextools package)
  • Less buggy than Atom
  • Looks beautiful.
  • Unicode character insertion not good (anymore).
  • Git integration ok, but takes some setting up.
hello

Visual Studio Code

  • Made by Microsoft, but open source.
  • Probably the best all-round text editor.

VS Code

  • Excellent git integration (Microsoft own Github)
  • Very stable
  • Very easy to customise
  • Unicode integration is outstanding.
  • LaTeX integration not great.
    • Reverse search difficult to configure
    • Bibliography search not as good as others.
hello

Emacs

  • Open Source.
  • Long history, big community

Emacs

  • Small installation.
  • Lots beyond LaTeX
  • Excellent LaTeX integration through AUCTeX and RefTeX.
  • You can play tetris/snake etc 😀
  • Not intutive to customise (lisp script, GUI very dense)
  • No project overview by default, but possible.
  • You can play tetris/snake etc 😒
hello

Vim

  • Terminal editor
  • Long history, large community
  • Small installation
  • LaTeX integration through VimLaTeX or vimtex.
  • Bonus: You look objectively more awesome writing in a terminal window 😎

(I don't use Vim enough to give advantages/disadvantages)

Using your editor the right way

Getting started

  1. Download your editor of choice.
  2. Install LaTeX builder.
  3. Install LaTeX language support.
  4. Go.

Demo

  1. Go to https://atom.io, download and install.
  2. Open, hit ctrl+,/cmd+, and click 'install' on the left.
  3. Search 'latextools' and install it
  4. Search for 'language-latex'
  5. Search for and install 'pdf-view'
  6. Now, you're good to go.

Using Markdown instead

RMarkdown

  • If you use RMarkdown, there is no dedicated environment, like RStudio.
  • But, you can follow the above steps to enable markdown support, then call knitr from your terminal.
  • To do so, run the commands:
                    
$ R
> install.packages('rmarkdown')
> rmarkdown::render('FILE.Rmd')
                    
                

Atom + Latextools: Basic Workflow

  • Open .tex file.
  • Write something latex-y
  • Hit ctrl-alt-b or cmd-alt-b
  • It should then open in the pdf-viewer at the side.

Other commands: latextools

  • ctrl-l escape/cmd-l escape = close console
  • ctrl-l ctrl-n/cmd-l cmd-n = wrap in environment
  • ctrl-l j/cmd-l j = jump to pdf

Saving yourself time: snippets

  • Atom, Sublime, VSCode etc. allow you to define your own pieces of code, that insert wider chuncks.
  • Idea
    1. type a sequence of characters (snippet) and hit tab.
    2. The content of the snippet will then be inserted

Writing Snippets in Atom

  • Snippets need four things:
    1. Scope = which language it will work in
    2. Name = for comprehension
    3. Prefix = the shortcut
    4. Body = what is inserted

Unicode

Clarity

  • Useful for non-latin characters and diacritics.
  • LaTeX markup is messy, especially with symbols.
  • Some are intutive: \v{s} = sĖŒ
  • Others are not: \textipa{@} = ə

Unicode

  • Unicode is useful because you type the characters directly, using a standardised code.
  • Requirements:
    1. Unicode compatible font.
    2. The right code.
    3. Ability to input the code.

Unicode: Advantages

  • Your writing is a lot more readable in the editor.
  • You can reuse the code: just copy paste into email, markdown documents, excel, word etc.
  • Works well in bibliographies (with Biber).

Unicode fonts

Inputing the code

  • System: ctrl-shift-u in linux.
  • Within the editor:
    • Atom: Character Table
    • VSCode: Insert Unicode
    • Emacs: ctrl-x 8 enter
    • Sublime: not honestly sure. There used to be Character Table, but it's disappeared of late.

The right code

Misc Tips

Handling larget documents

  • For a thesis, it's a good idea to keep each chapter as its own file, and compile from a master file.
  • Use the \include{} command.
  • (or use \input{})
                    
\documentclass{memoir}
...
\title{Thesis}
\author{G. K. Candidate}
\date{Summer 2020}
\begin{document}
\include{intro.tex}
\include{theoretical_background.tex}
\include{content1.tex}
\include{content2.tex}
\include{conclusions.tex}
\printbibliography
\end{document}