Skip to content

tengssh/latex_basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 

Repository files navigation

Introduction to LaTeX

LaTeX basics

  • LaTeX commands: \command[option,...]{argument}
  • 10 special characters: # $ % & ~ _ ^ \ { }
  • \documentclass[OPTIONS]{CLASS}: layout of the document
    • CLASS
      • Basic: article, book, report, letter, slides, beamer
      • American Mathematical Society (AMS): amsbook, amsarticle
      • KOMA-Script: scrartcl, scrbook, scrreprt, scrlttr2
      • Book: tufte-book
      • Journals: revtex4-2, elsarticle
    • OPTIONS
      • letterpaper, a4paper
      • 10pt, 11pt, 12pt
      • fleqn, leqno
      • titlepage, notitlepage
      • oneside, twoside
      • onecolumn, twocolumn
      • landscape
      • openright, openany
      • draft, final
  • \begin{}, \end{}: define an environment
    \begin{document}
      \begin{environment1}
        \begin{environment2}
      \end{environment1}
        \end{environment2}
    \end{document}
  • \title{}
  • \date{}
    • \today
  • \author{}
  • \newpage
  • \pagestyle{STYLE}, \thispagestyle{STYLE}
    • empty, plain, headings, myheadings, fancy
  • \pagenumbering{}
    • gobble, arabic, roman
  • Texts
    • \text{}: normal text
    • \textbf{}: bold
    • ~: a non-breaking space between texts (e.g. 3.5~mm)
    • \\: line break
    • \verb|LaTeX-COMMAND| (| can be replaced with other characters), \begin{verbatim}LaTeX-COMMAND\end{verbatim}: display LaTeX commands
  • Table of contents
    • \tableofcontents
      • In preamble: \setcounter{tocdepth}{n}, where n = 1, 2, 3(default), 4, 5
      • Specify individually before each section: \addtocontents{toc}{\setcounter{tocdepth}{3}}
    • \listoffigures, \listoftables
  • \part{}
  • \chapter{} (only books and reports)
  • Sections: \section{}, \subsection{}, \subsubsection{}, \section*{WITHOUT NUMBERING}
  • Paragraphs: \paragraph{}, \subparagraph{}

Math

  • Math environments: $INLINE_FORMULA$, \(INLINE_FORMULA\), equation, align, subequations

Figure

  • Figure environments
    • \begin{figure}[placement specifier]
      • h (here, if possible), t (top), b (bottom), p (page of floats), ! (override)
      • H (here, definitely) if \usepackage{float}
    • \begin{subfigure}[pos][height][inner-pos]{width}
      • pos: c (center, default), t (top), b (bottom)
      • height: strech the height of the subfigure (e.g. 10pt, 1cm)
      • inner-pos: t (top), c (center), b (bottom), s (stretch)
      • width: width of the subfigure
    • \begin{wrapfigure}[nline]{pos}[overhang]{width} (if \usepackage{wrapfig})
      • nline: number of narrow lines (e.g. 12)
      • pos: R/r (right), L/l (left), I/i (inside), O/o (outside) [float/no]
      • overhang: overhang of the figure (0pt, default)
      • width: width of the figure
    • \includegraphics[width=SIZE\textwidth]{FIGURE_PATH}
      • SIZE: 0~1 (use 0.1 less than you expect)
    • \caption{}
    • \label{MARKER}: this MARKER can be used for later referencing
    • \centering
    • \hfill: make one figure left-align and the other right-align, then fill spaces to produce a rubber length (same as \hspace\fill)
    • \hspace{L cm}: L can be a positive or negative value.
    • \ContinuedFloat: preserve the numbering from the previous subfigures
  • Set path to figure folder: \graphicspath{{FOLDER_PATH1}{FOLDER_PATH2}...}

Table & List

  • Table environment
    • begin{table}
    • begin{tabular}{| l | c | r |}
      • l: left-alignment, c: center-alignment, r: right-alignment, S: aligned decimal point (if \usepackage{siunitx})
      • |: vertical line, \hline: horizontal line
      • in each row: column1 & column2 & column3 \\
      • for \usepackage{multirow}
        • multiple rows: \multirow{NROWS}{WIDTH}{CONTENT}
        • multiple columns: \multicolumn{NCOLUMNS}{ALIGNMENT}{CONTENT}
      • for long table, \usepackage{longtable}
        • \begin{longtable}[placement specifier]{ALIGNMENT}
        • Put the header between \endfirsthead and \endhead so that it will be shown on every page.
      • usepackage{rotating} to rotate the table
        • \begin{sidewaystable}
  • List environment
    • \begin{itemize}, \begin{enumerate}
      • \item ITEM 1
      • \item ITEM 2
      • \item ITEM n
    • To change the bullet point symbol
      • \item[?]
      • usepackage{enumitem}, usepackage{pifont}
  • LaTeX tables generator

Appendix & Bibliography

  • Appendix environment
    • \begin{appendix}
  • Referencing
    • \label{KEY}
    • \ref{KEY}, \subref{KEY}, \pageref{KEY}, \eqref{KEY}
    • \footnote{\label{FOOTNOTE_LABEL} CONTENT}, this footnote can be referred by using \ref{FOOTNOTE_LABEL}
    • \index{KEY} (if \usepackage{makeidx})
      • \makeindex, \printindex
    • usepackage{hyperref}
      • \hyperref[KEY]{TEXT} & \hypertarget{KEY}{TEXT}
      • \url{URL}, \href{URL}{TEXT}, href{mailto:EMAIL}{TEXT}, \href{run:PATH/FILE}{TEXT}
      • \hypersetup{OPTION1=VALUE1,OPTION2=VALUE2,...} (more information can be found in LaTeX/Hyperlinks)
    • usepackage{varioref}
      • \vref{KEY}
    • usepackage{cleveref}
      • \cref{KEY}, \Cref{KEY}
  • Bibliography

Presentation

  • LaTeX presentation environment
    • begin{beamer}
  • Themes
    • \usetheme{default}
      • Boadilla, Madrid, Montpellier, Warsaw, ,Copenhagen, Goettingen, Hannover, Berkeley
  • Title page
    • \title{}, \subtitle{}, \author{}, \date{},
    • \titlegraphic{}
    • \titlepage
  • Logo
    • \logo{}
  • Section
    • \section{}
  • Frame
    • \begin{frame}[label={LABEL}]{TITLE}{Subtitle}
  • Hyperlink
    • \hyperlink{LABEL}{\beamerbutton{TEXT}}

Poster

  • TikZ poster
    • \documentclass[FONT_SIZE, PAPER_SIZE, ORIENT]{tikzposter}
      • FONT_SIZE: 12pt, 14pt, 25pt, ...
      • PAPER_SIZE: a0paper, a1paper, a2paper, a3paper, a4paper
      • ORIENT: landscape, portrait
    • \usetheme{}
      • Default, Rays, Basic, Simple, Envelope, Wave, Board, Autumn, Desert
    • Title
      • \maketitle
    • Block
      \block{TITLE}
      {
        TEXT
      }
    • Columns
      \begin{columns}
        \column{WIDTH}
        \block{TITLE}{}
        \column{WIDTH}
        \block{TITLE}{}
      \end{columns}
  • Beamer poster
    • \documentclass{beamer} + \usepackage[orientation=portrait,size=a0,scale=1.4]{beamerposter}
      • orientation: landscape, portrait
      • size: a0, a1, a2, a3, a4
      • scale
    • Themes
      • \usetheme{}
        • AnnArbor, Antibes, Bergen, Berkeley, Berlin, Boadilla, boxes, CambridgeUS, Copenhagen, Darmstadt, default, Dresden, Frankfurt, Goettingen, Hannover, Ilmenau, JuanLesPins, Luebeck, Madrid, Malmoe, Marburg, Montpellier, PaloAlto, Pittsburgh, Rochester, Singapore, Szeged, Warsaw
      • \usecolortheme{}
        • albatross, beaver, beetle, crane, default, dolphin, dove, fly, lily, orchid, rose, seagull, seahorse, sidebartab, structure, whale, wolverine
      • https://deic.uab.cat/~iblanes/beamer_gallery/index.html
    • Block
      \begin{frame}{}
        \begin{block}{TITLE}
          TEXT
        \end{block}
      \end{frame}
    • Columns
      \begin{frame}{}
      \begin{columns}[t]
        \begin{column}{WIDTH}
          \begin{block}{TITLE}
          \end{block}
        \end{column}
        \begin{column}{WIDTH}
          \begin{block}{TITLE}
          \end{block}
        \end{column}
      \end{columns}
      \end{frame}

Journals

Miscellaneous

LaTeX packages

  • LaTeX packages: \usepackage{PACKAGENAME}
    • all packages must be imported at the beginning
    • inputenc: input encodings
    • fontenc: font encodings
    • geometry: for page formatting, please refer to geometry document for more details.
    • parskip: change the spacing between paragraphs
    • setspace: change the spacing for table of contents by using \singlespacing, \doublespacing
    • babel: multilingual support
    • amsmath:
      • equation numbering can be removed when using begin{equation*} x=y end{equation*} or \nonumber at the end of the equation
      • adding text in the equation with \text{TEXT}, \mbox{TEXT}
    • graphicx: for figure environment
    • subcaption: for subfigure environment
    • wrapfig: for figures which text can flow around
    • booktabs: for tabular environment, \hline can be replaced by \toprule, \midrule and \bottomrule
    • tikz: for drawing, please visit TIKZ Blog for more examples
    • circuitikz: for drawing circuit diagram
    • siunitx: for aligning the decimal point
      • \sisetup{round-mode= places, round-precision= 3} (round-mode: places, figures)
    • multirow: for multiple rows in one cell
    • longtable: for long table
    • rotating: rotate the table
    • pgfplotstable: for autogenerated .csv tables
    • pgfplots: (part of tikz) for autogenerated plots
    • listings: for source code listings, another alternative is minted
    • hyperref: for hyperlinks
    • varioref: for cross-referencing on a different page
    • cleveref: for cross-referencing with automatic formatting
    • makeidx: for creating indexes, i.e. \makeindex
    • enumitem: for changing the bullet point symbol
    • pifont: for more bullet point styles, more symbols can be found in the manual
    • blindtext, lipsum: generate dummy text
    • beamer & beamerposter: for presentations & posters
    • xcolor: using named colors, please refer to manual for more details
    • overpic: picture environment for overlaying figures and annotations, please refer to manual for more details
    • fancyhdr: page headers and footers, more details in manual
    • datatool, databar: for data processing, management, and visualization

Examples

References

About

A simple manual for using LaTeX

Resources

Stars

Watchers

Forks