Skip to content

Commit

Permalink
some LaTeX
Browse files Browse the repository at this point in the history
  • Loading branch information
petry078 authored Jan 16, 2024
1 parent f433e3d commit 5456002
Showing 1 changed file with 166 additions and 22 deletions.
188 changes: 166 additions & 22 deletions docs/posts/latex-pdf-press.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,41 @@ LaTeX document structure is defined by header, that contains metadata and inform

#### Header commands

| Command | Definition |
|----------------------|------------|
| \documentclass[]{} | Initialize the document. Requires parameters `[]` and actual document class `{}`. |
| \usepackage[]{} | Import packages with additional functionality. Requires parameters `[]` and scope `{}`. |
| Command | Definition |
|-------------------------------|------------|
| `\documentclass[]{}` | Initialize the document. Requires parameters `[]` and actual document class `{}`. |
| `\usepackage[]{}` | Import and use packages with additional functionality. Requires parameters `[]` and scope `{}`. |
| `\setlength{\parindent}{0cm}` | Set paragraph identation. |
| `\setlength{\parskip}{2em}` | Set space between paragraphs. |
| `\renewcommand{\baselinestretch}{1.5}` | Space between lines. |
| `\title{Document title}`
| `\author{Document author}`
| `\date{Document date}`
|


###### \documentclass

`\documentcalss` parameters[], or parameters in genereal, are optionals and will change based on the actual class and command, that can be:

```tex
\documentclass{article}
\documentclass{report}
\documentclass{book}
\documentclass{letter}
\documentclass{slides}
\documentclass{beamer}
```

`\documentclass` parameter:

```tex
\documentclass[12pt]{}
\documentclass[a4paper]{}
\documentclass[twocolumn]{}
\documentclass[twoside]{}
\documentclass[landscape]{}
```

###### \usepackage

Must be right above the `\documentclass`.
Expand All @@ -76,9 +102,9 @@ Here are some popular packages and how to cast then.
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{graphicx}
\usepackage{url}
```


#### Content commands and techniques

Content commands are only allowed in the document scope:
Expand All @@ -90,32 +116,149 @@ Content and content commands go here! Like \LaTeX!
```

##### Content commands:

| Command | Definition |
|---------------------------|------------|
| `\\` | Line break, necessary on blank lines |
| `\textbf{Bold example}` | Initialize the document. Requires parameters `[]` and actual document class `{}`. |
| `\textit{Italic example}` | Import packages with additional functionality. Requires parameters `[]` and scope `{}`. |

##### Content commands

| Command | Definition |
|----------------------------------|---------------------------------------------------------------------------------------------------------------------|
| `\par` | New paragraph |
| `\\` | Line break, necessary on blank lines |
| `\textbf{Bold example}` | Bold text. |
| `\textit{Italic example}` | Italic text. |
| `\underline{Underline example}` | Underlined text. |
| `\begin{center}` | Text align: center. Requires `\end{center}` |
| `\begin{flushright}` | Text align: right. Requires `\end{flushright}` |
| `\newpage` or `\clearpage` | Page break. Needs test, as they work diffrently. |
| `\vspace{4cm}` | Add vertical space between elements in line. |
| `\hspace{4cm}` | Add horizontal space between elements in line. |
| `\hfill` and `\vfill` | Fill horizontal and vertical space between elements in line. |
| `\begin{itemize}` or `\begin{enumerate}` | Iniciates unordered or ordered list. Requires `\end{itemize}` or `\end{enumerate}`. For list item: `\item`. |
| `\begin{figure}` | Iniciates image with standard snippet. Requires graphicx package `\usepackage{graphicx}` in the document header. |
| `\begin{tabular}` | Iniciates image with standard snippet. Requires graphicx package `\usepackage{graphicx}` in the document header. |
| `\begin{titlepage}` | Iniciate title page. Requires `\end{titlepage}`. See example below. |
| `\tableofcontents` | Print table of contents. Nice to have `\newpage` after the summary. |
| `\listoffigures` | Print figures list. |
| `\listoftables` | Print figures list. |

##### Content techniques

Paragraphs are confusing. It needs to be like this, because whitespaces are considered all of the same thing:
Paragraphs must end with `\par`.

For a simple line break, use `\\` or `\newline` at the end of the paragraph, or in a single line.

```tex
First paragraph.
\\
Second paragraph.
\\
Third paragraph.
\\
...
Fisrt paragraph\par
Second paragraph\par
Simple line break\\
Newline \newline
```

> Crazy old tech stuff...
Whitespaces after commands are ignored. To print then, type the whitespace inside the commands scope {}. Example: `textbf{text }`.

`\hfill` and `\hspace{3cm}` examples:

```tex
Grape\hfill100g
1\hspace{1cm}2\hspace{1cm}3\hspace{1cm}4\hspace{1cm}
```

Inline font size and style:

```tex
\tiny{tiny text}\\
\scriptsize{scriptsize text}\\
\footnotesize{footnotesize text}\\
\small{small text}\\
\normalsize{normalsize text}\\
\large{large text}\\
\Large{Large text}\\
\LARGE{LARGE text}\\
\huge{huge text}\\
\Huge{Huge text}\\
\textrm{Roman Serif font}\\
\textsf{Sans Serif font}\\
\texttt{Monospaced font (typewriter)}\\
```

Any text style + any nother text style:

```tex
\underline{\textbf{\textit{Underlined, bold, and italic text}}}
```

Unordered list:

```tex
\begin{itemize}
\item 1
\item 2
\item 3
\item 4
\end{itemize}
```

Ordered list:

```tex
\begin{enumerate}
\item 1
\item 2
\item 3
\item 4
\end{enumerate}
```

Images are called figures in LaTeX, type `\begin{figure}` and it should autocomplete to this:

```tex
\begin{figure}
\centering
\includegraphics[scale=0.5]{imageExample.png}
\caption{Caption text}
\label{fig:enter-label}
\end{figure}
```

> Tables are too complicated, use online table generators or use Markdown inside LaTeX.
Title page:

```tex
\begin{titlepage}
\centering
\Huge{\textbf{University of Chaos}}
\vfill
\huge{My very long article title}
\vfill
\large{\textbf{Alum: Guilherme Petry}}
\vfill
\today
\end{titlepage}
```

Chapters, sections, and subsections:

```tex
\chapter{Chapter 1}
\section{Chapter 1, Section 1}
\section{Chapter 1, Section 2}
\subsection{Chapter 1, Section 2, Subsesummaryction 1}
\section{Chapter 1, Section 3}
\subsection{Chapter 1, Section 3, Subsection 1}
\subsection{Chapter 1, Section 3, Subsection 2}
```

> Use * in the end of markup to avoid it beeing indexed by the `\tableofcontents`. Example: `\section*{Chapter 1, Section 1}`
Note footers:

```tex
Primeiro parágrafo do capítulo 1, seção 3 e subseção 2\footnote{Nota de rodapé1}\par
Segundo parágrafo do capítulo 1, seção 3 e subseção 2\footnote{Nota de rodapé2}\par
```

### Comments

## ABNT
Expand All @@ -128,6 +271,7 @@ If you don't know what this is. Trust me, you don't need it.
* Learn: https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes#What_is_LaTeX?
* ABNT: https://github.com/abntex/abntex2/wiki/InstalacaoLinux#instala%C3%A7%C3%A3o-autom%C3%A1tica-do-texlive-e-do-abntex2-em-distribui%C3%A7%C3%B5es-debian-ubuntu-e-derivadas-recomendado
* Learning playlist (UFMG): https://youtube.com/playlist?list=PLt2qoMeOJsQzWsM5vM7eWFUZKVbCZmWZB&si=M8rouIXyLS7dUfrb
* Parei em Aula 2.6: Referências Cruzadas | Preparação de Documentos em LaTeX: https://youtu.be/9mkGr-YSVHA?si=Xrp4AYw6JvxK7ddP

<div class="wisdom">
<img class="wisdony" src="https://upload.wikimedia.org/wikipedia/commons/a/ae/Cups07.jpg" alt="">
Expand Down

0 comments on commit 5456002

Please sign in to comment.