- Complex mathmatics, tables and technical contents
- Footnotes, cross-ref, biblio
- Indexes, Glossaries, ToC, List of Figures, List of Tables,...
- Highly customizable, intrinsic programmability
- Thousands of free add-ons
- LaTeX file create template which author can use to write many papers
- Thousand of templates: articles, reports, books, CVs, ...
Between \begin{document}
and \end{document}
- Overleaf only grab
main.tex
file in a project - Before
\begin{document}
is called preamble - Define language, loading packages,
\documentclass[12pt, a4paper]{article | report | book | ...}
- Parameters are defined in square bracket
- 12pt = font size (alter: 9pt, 11pt, 13pt, ... Def = 10pt)
- a4paper = paper size (alter: letterpaper, legalpaper)
- Defined in Prem.
\title{My first LaTeX document}
\author{VH\thanks{Teached by Overleaf}}
\date{December 2023}
or\today
- Typeset the 3, use
\maketitle
in Body.
\textbf{...}
\textit{...}
, alter =\emph{...}
, use with italic will turn it back to normal\underline{...}
- Insert Figure button.
- Copy and paste image.
- Use Code Editor write code insert image.
% Prem
\usepackage{graphicx}
\graphicspath{{images/}} % Configure the dir that graphicx will search for images
% Body
\includegraphics{universe} % load an img called universe.jpg in images dir
- Omit the file extension: \includegraphics{universe} not \includegraphics{universe.jpg}
- Not whitespace of multiple dots in filename, extension part must be lowercase.
% Prem
\usepackage{graphicx}
\graphicspath{{images/}}
% Body
\begin{figure}[h] % positioning of figures
\centering % use to center anything after it
\includegraphics[width=0.75\textwidth]{mesh} % text width is stored in \textwidth command
\caption{A nice plot.} % can be placed above or below
\label{fig:mesh1} %
\end{figure}
\ref{fig:mesh1} % the name of figure
\pageref{fig:mesh1} % the number of the page that contains the figure
Environments: encap the latex code req to implement a specific typeset feature.
% Body
\begin{figure | tabular | ...}
\end{...}
% Body
\begin{itemize}[label=$\circ$]
\item[] The item has no bullet point
\item This item has default bullet point
\item[-] This item's bullet point has changed
\end{itemize}
% Body
% Numbering style can be changed
\begin{enumerate}
\item First entry
\item The list numbers increases with each entry added
2 ways:
- inline: formula that's part of paragraph. 3 syntax:
\( ... \)
$ ... $
\begin{math} ... \end{math}
- display: formula that is seperate line. 3 syntax:
\[ ... \]
\begin{displaymath} ... \end{displaymath}
\begin{equation} ... \end{equation}
% Body
% Inline
Equation $E=mc^2$, discovered in 1905 by Albert Einstein.
% Display
The mass-energy equivalence is described by the famous equation
\[E=mc^2\]
discovered in 1905 by Albert Einstein.
Brief overview/summary of their core topics, arguments.
Using abstract
environment
% Body
\begin{abstract}
...
\end{abstract}
3 syntex:
Enter
twice (or blank line between 2 paragraph)\\
command\newline
command
Note: LaTeX auto indents paragraph, except right after headings
\usepackage{parskip}
manipulate paragraph
book
class = **chapters + sections + subsections + ...```letter
class, is diff
% Prem
\documentclass{book}
% Body
\chapter{First Chapter}
\section{Introduction}
\subsection{...}
\subsubsection{...}
% less encounter
\part{...}
\paragrapth{...}
\subparagraph{...}
\begin{center} % align center to whole table within text width of the page
\begin{tabular}{|c||c|c|} % c = align center to column, | = vertical rules, 2 rules is also okey
\hline % horizontal rules
\hline % two rules is also okay
cell1 & cell2 & cell3 \\ % & = delimiter for each columns
\hline
cell4 & cell5 & cell6 \\ % end a table row use the newline \\
\hline
cell7 & cell8 & cell9
\end{tabular}
\end{center}
\begin{table}[h!] % or H
\centering % alter to \begin{center} ... \end{center}
\begin{tabular}{||c c c c||}
...
\end{tabular}
\caption{Table to test captions and labels}
\label{table:data}
\end{table}
Table \ref{table:data} shows how to add a table caption and ref a table on \pageref{table:data}
\tableofcontents
Unnumbered section don't get included in ToC by default:
\addcontentsline{toc}{section}{Unnumbered Section}
\addcontentsline{toc}{subsection}{Unnumbered Subsection}
\usepackage{somepackage}
: load package using default settings
\usepackage[options]{somepackage}
: load package using modified settings
\usepackage[total={6.5in,8.75in},top=1.2in, left=0.9in, includefoot]{geometry}
% Method 1
\usepackage[legalpaper, landscape, margin=2in]{geometry}
% Method 2
\usepackage{geometry}
\geometry{legalpaper, landscape, margin=2in}
% Change margin
\usepackage{geometry}
\geometry{
a4paper,
total={170mm,257mm},
left=20mm,
top=20mm,
}
\usepackage{layout}
: visualize the documents current layout
\layout
vs \layout*
, the latter recal internal vals used to draw the graphic
\vspace{10pt}
add vertical space
setlength{\<parameter>}{?pt}
\layout*
\blindtext[10]
\usepackage{blindtext}
[h]
: place the float at approx location in the LaTeX code[H]
: place the float at precisely location in the LaTeX code[t]
: top page[b]
: bottom page[p]
: special page for float only[<htbpH>!]
: override for determining "good" float positions.
Note: use H
or h!
, need these lines:
\usepackage{float}
\restylefloat{table}