Product Design, Manufacturing & Innovation Resources
Lar » Design de produto » Dicas de design » Guia completo de LaTeX para escrever fórmulas

Guia completo de LaTeX para escrever fórmulas

Folha de referência do LaTeX

Na engenharia e na academia, a importância da preparação de documentos de alta qualidade é inegável. O LaTeX, um sistema de composição tipográfica reverenciado por sua precisão e flexibilidade, aprimora a qualidade de documentos técnicos, tornando-se a escolha preferida entre acadêmicos e profissionais. De acordo com uma pesquisa de 2019 realizada pela Overleaf e pela ACM, mais de 80% dos pesquisadores em áreas como ciência da computação e matemática confiam no LaTeX por sua capacidade superior de lidar com documentos complexos, principalmente aqueles com conteúdo matemático intrincado. Este artigo oferece um guia completo e abrangente da linguagem LaTeX, com exemplos detalhados dedicados à escrita de fórmulas.

Principais conclusões

Formulas
Criando fórmulas precisas para eficácia design de produto e soluções de engenharia.
  • O LaTeX separa o conteúdo do layout de forma eficaz.
  • A estrutura inclui componentes de preâmbulo e corpo.
  • A notação matemática integra-se perfeitamente ao texto.
  • As figuras e tabelas podem ser consultadas facilmente.
  • Outras bibliotecas, como o BibTeX, simplificam o gerenciamento de citações de forma impressionante.

Seja para elaborar uma tese, um relatório técnico ou um artigo científico, dominar o LaTeX pode agilizar significativamente o seu trabalho. publicação Aprimore e eleve seu trabalho tanto em ambientes acadêmicos quanto industriais.

Em sua essência, o LaTeX é um sistema de preparação de documentos e uma linguagem de marcação de alto nível, renomado por sua capacidade de produzir documentos tipográficos profissionais, especialmente aqueles que contêm fórmulas matemáticas complexas e notações científicas. Foi originalmente escrito por Leslie Lamport no início da década de 1980 como um aprimoramento mais amigável ao usuário do programa de composição tipográfica TeX, desenvolvido por Donald Knuth.

Introdução ao LaTeX e suas vantagens em relação aos editores WYSIWYG

Látex
O LaTeX aprimora o design de produtos e a inovação em documentação científica por meio de formatação superior e gerenciamento de citações.

O LaTeX, um sistema de composição tipográfica, oferece inúmeras vantagens que atendem à preparação de documentos complexos, especialmente nas áreas científica e técnica. Um dos principais benefícios é sua capacidade de lidar com tarefas complexas de layout e formatação de forma impecável, algo que um editor WYSIWYG típico geralmente não consegue fazer. Por exemplo, o robusto gerenciamento de bibliografias, citações e referências pelo LaTeX o torna a escolha ideal para profissionais envolvidos em pesquisa, onde precisão e exatidão são fundamentais.

Outra vantagem notável é a qualidade superior dos documentos criados com LaTeX. O sistema segue as melhores práticas tipográficas, garantindo que o documento final não seja apenas esteticamente agradável, mas também atenda aos altos padrões de publicação. padrões.

The version control capabilities of LaTeX further distinguish it from standard editors. Through text files, multiple authors can collaborate using software tools like Git, which track changes effectively. This feature resolves conflicts more efficiently than traditional editors, as only the text is modified without disrupting the formatting. For equipes engaged in large-scale projects, this approach significantly enhances collaboration.

Por fim, a flexibilidade do LaTeX permite que os usuários criem estilos e comandos personalizados, tornando-o adaptável a uma ampla gama de necessidades de documentação. Sejam artigos acadêmicos ou relatórios comerciais, os usuários podem definir suas próprias regras de formatação. Essa personalização é algo geralmente inatingível com editores WYSIWYG.

Dica: Utilize pacotes como o TikZ para criar diagramas complexos em seus documentos, a fim de aprimorar a clareza visual e, ao mesmo tempo, aproveitar os recursos do LaTeX (consulte nosso Bônus nº 2 abaixo mais bibliotecas).

Basic Document Structure in LaTeX

LaTeX documents begin with the declaration of the document class, which defines the overall layout and formatting. Commonly used classes include artigo, report, e book. This starts with the command documentclass{article}. A typical LaTeX document has a preamble that includes packages for enhanced functionality, such as usepackage{amsmath} for mathematics and usepackage{graphicx} for image handling. The structure follows with the begin{document} command, indicating where the content begins, ending with end{document}.

Dica: use the label{key} command right after the section command to create cross-references. This allows automatic numbering and accurate reference updates throughout the document, improving workflow efficiency. An example is creating labels for equations or sections which can then be referenced with ref{key}, ensuring consistency.

Dica: to achieve consistent formatting across large documents, it’s advised to utilize pre-defined styles or templates available in LaTeX.

Mathematical Expressions and Equation Formatting

LaTeX provides extensive capabilities for rendering mathematical expressions and equations, allowing users to format them with precision. The language supports two main environments for displaying math, “inline” and “display”:

  • “Inline math”, enclosed by $…$, when LaTex is used within a paragraph
  • “Display math”, enclosed by […], centers the equation on its own line for better visibility

For example, an inline expression such as $E = mc^2$ will rendered as \(E = mc^2\) where a display version [E = mc^2] will render as :
\(E = mc^2\)
where the latter is rendered more prominently.

 

Super Tip: you may encounter the notation $ $…$ $ (double $ on both sides) instead of […], despite the American Mathematical Society (AMS) discouraged it. 

IMPORTANT: for clarity, from now on, all the examples below will omit the “$…$” (inline mode) and “[…]” (display mode), to focus on the exact LaTeX feature.

Formatting of mathematical symbols is straightforward in LaTeX. Users can create fractions, roots, and subscripts with ease:

Format TypeCommand
Fractions\frac{a}{b} will render as: \(\frac{a}{b}\)
Square Roots\sqrt{x} will render as \(\sqrt{x}\)
Subscriptx_i will render as \(x_i\)

Within LaTeX, one can manipulate mathematical spacing and alignment. For instance, the commands , (thin space), : (medium space), and ; (thick space) allow for adjustments between operators or symbols. When presenting data, items can also be arranged in tables.

To enhance mathematical formatting, LaTeX supports environments for alignment. The “align” environment allows multiple equations to be aligned at the equal sign, a feature particularly beneficial in formal presentations. By incorporating tags such as begin{align}…end{align}, one can align equations neatly. Using LaTeX not only enhances the appearance of mathematical content but also maintains consistency across various documents.

The Complete LaTex Cheat Sheet for Formulas

 

FeatureExplanationCode Examples
reminder: except for the 2 first mode examples, all the examples below will omit “$…$” and “[…]”
Rendered Examples
Inline Math ModeUsed to write formulas that are part of a paragraph or running text. The text and the formula will be on the same line.The equation is $E=mc^2$.


Another example is $\(a^2 + b^2 = c^2\)$.

The equation is \(E=mc^2\).


Another example is \(a^2 + b^2 = c^2\).

Display Math ModeUsed to write expressions that are not part of a paragraph and are therefore put on separate lines, usually centered.The equation is [E=mc^2]


[x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}]

The equation is

\(E=mc^2\)

\(x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}\)

Equation Environment (Numbered)Similar to display math mode, but it automatically numbers the equation.\begin{equation} F = ma \end{equation}


\begin{equation} \oint_C \mathbf{B} \cdot d\mathbf{l} = \mu_0 I_{enc} \end{equation}

\(\begin{equation} F = ma \\ \oint_C \mathbf{B} \cdot d\mathbf{l} = \mu_0 I_{enc} \end{equation}\)
Equation* Environment (Unnumbered)Displays an equation on its own line, centered, but without a number. Requires the “amsmath” package.\begin{equation*} E \neq mc^3 \end{equation*}


\begin{equation*} \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} \end{equation*}

\(\begin{equation*} E \neq mc^3 \end{equation*}\)


\(\begin{equation*} \nabla \cdot \mathbf{E} = \frac{\rho}{\epsilon_0} \end{equation*}\)

Superscripts (Exponents)To create a superscript (exponent), use the caret symbol ^. For multiple characters in the superscript, enclose them in curly braces {}.x^2


e^{i\pi} + 1 = 0

\(x^2\)


\(e^{i\pi} + 1 = 0\)

SubscriptsTo create a subscript, use the underscore symbol _. For multiple characters in the subscript, enclose them in curly braces {}.a_1


H_2O

\(a_1\)


\(H_2O\)

FractionsUse the \frac{numerator}{denominator} command to create fractions.\frac{1}{2}


\frac{d}{dx} \left( \frac{x^2+1}{x-1} \right)

\(\frac{1}{2}\)


\(\frac{d}{dx} \left( \frac{x^2+1}{x-1} \right)\)

Binomial CoefficientsUse the \binom{n}{k} command (from “amsmath” package) or {n \choose k} for binomial coefficients.\binom{n}{k}


{N \choose k+1}

\(\binom{n}{k}\)


\({N \choose k+1}\)

Square RootsUse the \sqrt{expression} command for square roots.\sqrt{x}


\sqrt{b^2-4ac}

\(\sqrt{x}\)


\(\sqrt{b^2-4ac}\)

Nth RootsUse the \sqrt[n]{expression} command for nth roots.\sqrt[3]{8}


\sqrt[n]{\frac{x}{y}}

\(\sqrt[3]{8}\)


\(\sqrt[n]{\frac{x}{y}}\)

SummationUse the \sum command for summation. Limits are placed using _ for lower and ^ for upper.\sum_{i=1}^{n} i^2


\sum_{k=0}^{\infty} \frac{1}{k!} = e

\(\sum_{i=1}^{n} i^2\)


\(\sum_{k=0}^{\infty} \frac{1}{k!} = e\)

ProductUse the \prod command for products. Limits are placed using _ for lower and ^ for upper.\prod_{j=1}^{m} x_j


\prod_{n=1}^{N} \left(1 + \frac{1}{n}\right) \]

\(\prod_{j=1}^{m} x_j\)


\(\prod_{n=1}^{N} \left(1 + \frac{1}{n}\right)\)

IntegralsUse the \int command for integrals. Limits are placed using _ for lower and ^ for upper.\int_a^b f(x) \, dx


\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}

\(\int_a^b f(x) \, dx\)


\(\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}\)

Other Integrals (oint, iint, etc.)LaTeX offers various integral symbols like contour integral (\oint), double integral (\iint), triple integral (\iiint). Requires amsmath package for some.\oint_C \vec{E} \cdot d\vec{l}


\iint_D f(x,y) \,dA

\(\oint_C \vec{E} \cdot d\vec{l}\)


\(\iint_D f(x,y) \,dA\)

LimitsUse the \lim command for limits. The subscript is specified using _.\lim_{x \to \infty} \frac{1}{x}


\lim_{n \to 0} \frac{\sin(n)}{n} = 1

\(\lim_{x \to \infty} \frac{1}{x}\)


\(\lim_{n \to 0} \frac{\sin(n)}{n} = 1\)

Parentheses, Brackets, BracesStandard characters (), [] can be used directly. For literal curly braces, use \{ e \}.(x+y)[z]


A = \{1, 2, 3\}

\((x+y)[z]\)


\(A = \{1, 2, 3\}\)

Automatic Sizing of DelimitersUsar \left e \right before delimiters (like (, ], \{, |) to make them automatically adjust their size to the height of the expression they enclose. Each \left must have a corresponding \right. Use . for an invisible delimiter (e.g., \left.).\left( \frac{a}{b} \right)


\left\{ \sum_{i=0}^n x_i \middle| x_i > 0 \right\}

\(\left( \frac{a}{b} \right)\)


\(\left\{ \sum_{i=0}^n x_i \middle| x_i > 0 \right\}\)

Greek Letters (Lowercase)Lowercase Greek letters are typed as \name, e.g., \alpha, \beta, \gamma.\alpha, \beta, \gamma


\theta = \frac{\pi}{4}

\(\alpha, \beta, \gamma\)


\(\theta = \frac{\pi}{4}\)

Greek Letters (Uppercase)Uppercase Greek letters are typed as \Name, e.g., \Gamma, \Delta. Some are the same as Latin letters (e.g., A for Alpha) and don’t have a special command.\Gamma, \Delta, \Sigma


\Omega = \frac{V}{I}

\(\Gamma, \Delta, \Sigma\)


\(\Omega = \frac{V}{I}\)

Mathematical FunctionsStandard functions like sin, cos, tan, log, ln, exp, etc., should be typed using a backslash to ensure they are typeset in upright font and not as variables. E.g., \sin(x) não sin(x).\sin(\theta) + \cos^2(\phi)


\log_b(x) = \frac{\ln(x)}{\ln(b)}

\(\sin(\theta) + \cos^2(\phi)\)


\(\log_b(x) = \frac{\ln(x)}{\ln(b)}\)

Modulo OperatorUsar \pmod{m} for congruence relations or \mod for the binary operator (amsmath).a \equiv b \pmod{n}


x = y \mod z

\(a \equiv b \pmod{n}\)


\(x = y \mod z\)

Mathematical AccentsAccents like hats, tildes, bars, dots, etc., are placed over characters.\hat{x}, \tilde{y}, \bar{z}


\vec{a}, \dot{q}, \ddot{p}

\(\hat{x}, \tilde{y}, \bar{z}\)


\(\vec{a}, \dot{q}, \ddot{p}\)

Wide AccentsFor accents over multiple characters, use commands like \widehat{} e \widetilde{}.\widehat{AB}


\widetilde{xyz}

\(\widehat{AB}\)


\(\widetilde{xyz}\)

Overbrace and UnderbracePlace horizontal braces above or below an expression using \overbrace{expression}^{label} ou \underbrace{expression}_{label}.\overbrace{a+b+c}^{group}


\underbrace{x_1 + x_2 + \dots + x_n}_{n \text{ terms}}

\(\overbrace{a+b+c}^{group}\)


\(\underbrace{x_1 + x_2 + \dots + x_n}_{n \text{ terms}}\)

Overline and UnderlinePlace horizontal lines above or below an expression using \overline{expression} ou \underline{expression}.\overline{A \cup B}


\underline{x+y}

\(\overline{A \cup B}\)


\(\underline{x+y}\)

Matrices and Arrays (array environment)O array environment is used to create matrices or tables within math mode. Column alignments are specified (c for center, l for left, r for right). Use & as column separator and \\ to start a new row. Often enclosed in delimiters like \left( \right) ou \left[ \right].M = \begin{pmatrix} a & b \\ c & d \end{pmatrix} (using amsmath pmatrix)


A = \left[ \begin{array}{cc|r} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array} \right]

\(M = \begin{pmatrix} a & b \\ c & d \end{pmatrix}\)


\(A = \left[ \begin{array}{cc|r} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array} \right]\)

Cases (cases environment)O cases environment (from amsmath package) is used for piecewise functions. Each case is on a new line, separated by \\. Text after & is typically the condition.f(x) = \begin{cases} x^2 & \text{if } x \ge 0 \\ -x & \text{if } x < 0 \end{cases}


|x| = \begin{cases} x & x > 0 \\ 0 & x = 0 \\ -x & x < 0 \end{cases}

\(f(x) = \begin{cases} x^2 & \text{if } x \ge 0 \\ -x & \text{if } x < 0 \end{cases}\)


\(|x| = \begin{cases} x & x > 0 \\ 0 & x = 0 \\ -x & x < 0 \end{cases}\)

Aligning Equations (align environment)

O align environment (from amsmath package) is used to align multiple equations, typically at the equals sign (or other relation symbols). Use & to mark alignment points and \\ to separate equations. Each line gets a number.

Dica: some rendering environments ask for “aligned” instead of the official “align”

\begin{align} a &= b + c \\ x &= y - z \end{align}


\begin{align} E &= mc^2 \\ F &= ma \end{align}

\(\begin{align} a &= b + c \\ x &= y – z \end{align}\)


\(\begin{align} E &= mc^2 \\ F &= ma \end{align}\)

Align* Environment (Unnumbered)Same as align, but does not number the equations. Requires amsmath package.\begin{align*} 2x + 3y &= 5 \\ x - y &= 1 \end{align*}


\begin{align*} \cos^2\theta + \sin^2\theta &= 1 \\ \sec^2\theta - \tan^2\theta &= 1 \end{align*}

\(\begin{align*} 2x + 3y &= 5 \\ x – y &= 1 \end{align*}\)


\(\begin{align*} \cos^2\theta + \sin^2\theta &= 1 \\ \sec^2\theta – \tan^2\theta &= 1 \end{align*}\)

Gather EnvironmentO gather environment (from the “amsmath” package) centers a group of equations without alignment. Each equation gets a number.\begin{gather} a^2 + b^2 = c^2 \\ x+y+z = 10 \end{gather}


\begin{gather} \int e^x dx = e^x + C \\ \frac{d}{dx} \sin(x) = \cos(x) \end{gather}

\(\begin{gather} a^2 + b^2 = c^2 \\ x+y+z = 10 \end{gather}\)


\(\begin{gather} \int e^x dx = e^x + C \\ \frac{d}{dx} \sin(x) = \cos(x) \end{gather}\)

Multiline Equations (multline environment)O multline environment (from the “amsmath” package) is for a single equation that needs to be broken into multiple lines. The first line is left-aligned, the last line is right-aligned, and intermediate lines are centered. Gets a single number.\begin{multline} a+b+c+d+e+f \\ +g+h+i+j+k+l \\ +m+n+o+p \end{multline}


\begin{multline} \text{long expression first part} \\ = \text{second part continued} \\ + \text{third part final} \end{multline}

\(\begin{multline} a+b+c+d+e+f \\ +g+h+i+j+k+l \\ +m+n+o+p \end{multline}\)


\(\begin{multline} \text{long expression first part} \\ = \text{second part continued} \\ + \text{third part final} \end{multline}\)

Split Environment (within another math env)O split environment (from the “amsmath” package) is used inside another display math environment (like equação ou align) to split a single equation into multiple lines with alignment, but it only gets one equation number for the whole block.\begin{equation} \begin{split} H_c &= \frac{1}{2n} \sum_{l=0}^{n-1} (-1)^l (n-l)^{p-2} \binom{n-1}{l} \\ & \quad \cdot [(N-l)\alpha N + N] \end{split} \end{equation}


\begin{equation} \begin{split} (a+b)^3 &= (a+b)(a+b)^2 \\ &= (a+b)(a^2+2ab+b^2) \\ &= a^3+3a^2b+3ab^2+b^3 \end{split} \end{equation}

\(\begin{equation} \begin{split} H_c &= \frac{1}{2n} \sum_{l=0}^{n-1} (-1)^l (n-l)^{p-2} \binom{n-1}{l} \\ & \quad \cdot [(N-l)\alpha N + N] \end{split} \end{equation}\)


\(\begin{equation} \begin{split} (a+b)^3 &= (a+b)(a+b)^2 \\ &= (a+b)(a^2+2ab+b^2) \\ &= a^3+3a^2b+3ab^2+b^3 \end{split} \end{equation}\)

Text in Math ModeTo include normal text (upright font, normal spacing) within a formula, use \text{your text here}. Requires the “amsmath” package.E=mc^2 \text{ (Einstein's equation)}


x = 5 \text{ if } y > 0

\(E=mc^2 \text{ (Einstein’s equation)}\)


\(x = 5 \text{ if } y > 0\)

Spacing in Math ModeLaTeX generally handles spacing well, but manual adjustments can be made with commands like \, (thin space), \: (medium space), \; (thick space), \! (negative thin space), \quad (em space), \qquad (2 em space).\int f(x) \, dx (thin space before dx)


a \quad b \qquad c

\(\int f(x) \, dx\)


\(a \quad b \qquad c\)

Dots (Ellipses)Various types of dots: \ldots (on baseline), \cdots (centered), \vdots (vertical), \ddots (diagonal).x_1, x_2, \ldots, x_n


A = \begin{pmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{pmatrix}

\(x_1, x_2, \ldots, x_n\)


\(A = \begin{pmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{pmatrix}\)

VectorsCommonly represented using \vec{v} for a small arrow above, or boldface \mathbf{v}.\vec{F} = m\vec{a}


\mathbf{x} \cdot \mathbf{y} = \sum x_i y_i

\(\vec{F} = m\vec{a}\)


\(\mathbf{x} \cdot \mathbf{y} = \sum x_i y_i\)

Special Symbols (Relational)Symbols like \leq (≤), \geq (≥), \neq (≠), \approx (≈), \equiv (≡), \subset (⊂), \in (∈).a \leq b \text{ and } x \neq y


A \subset B \text{ or } A \equiv B

\(a \leq b \text{ and } x \neq y\)


\(A \subset B \text{ or } A \equiv B\)

Special Symbols (Operators)Binary operators like \pm (±), \times (×), \div (÷), \cdot (·), \oplus (⊕), \otimes (⊗).x = \frac{-b \pm \sqrt{d}}{2a}


A \otimes B = C

\(x = \frac{-b \pm \sqrt{d}}{2a}\)


\(A \otimes B = C\)

Special Symbols (Arrows)Arrows like \rightarrow (→), \leftarrow (←), \Rightarrow (⇒), \Leftrightarrow (⇔), \mapsto (↦).x \rightarrow \infty


A \Rightarrow B \Leftrightarrow \neg A \lor B

\(x \rightarrow \infty\)


\(A \Rightarrow B \Leftrightarrow \neg A \lor B\)

Special Symbols (Miscellaneous)Symbols like \infty (∞), \nabla (∇, nabla), \partial (∂, partial derivative), \hbar (ħ, h-bar), \forall (∀, for all), \exists (∃, exists).\int_0^\infty e^{-x} dx = 1


\nabla \times \mathbf{B} - \frac{1}{c^2} \frac{\partial \mathbf{E}}{\partial t} = \mu_0 \mathbf{J}

\(\int_0^\infty e^{-x} dx = 1\)


\(\nabla \times \mathbf{B} – \frac{1}{c^2} \frac{\partial \mathbf{E}}{\partial t} = \mu_0 \mathbf{J}\)

Blackboard BoldUsed for number sets like Real numbers (ℝ), Complex numbers (ℂ), etc. Requires the "amsfonts" package (often included with “amsmath”). Command is \mathbb{R}.\in \mathbb{R}


z \in \mathbb{C} where z = a+bi

\(x \in \mathbb{R}\)


\(z \in \mathbb{C}\) where \(z = a+bi\)

Script (Calligraphic) LettersUsed for certain mathematical symbols or sets. Command is \mathcal{L}.mathcal{L} \{f(t)\} (Laplace Transform)


\mathcal{P}(S) (Power Set of S)

\(\mathcal{L} \{f(t)\}\)


\(\mathcal{P}(S)\)

Forcing Display StyleO \displaystyle command forces LaTeX to use the larger “display” style for a part of an inline equation, which is useful for fractions, sums, or integrals in running text to make them more readable.Inline fraction \frac{1}{2} vs \displaystyle \frac{1}{2}.


Inline sum \sum_{i=1}^n x_i vs \displaystyle \sum_{i=1}^n x_i.

Inline fraction \(\frac{1}{2}\) vs \(\displaystyle \frac{1}{2}\).


Inline sum \(\sum_{i=1}^n x_i\) vs \(\displaystyle \sum_{i=1}^n x_i\).

Tagging EquationsUsar \tag{label} within an unnumbered environment (like equation*) or to override the number in a numbered one to provide a custom label. Requires “amsmath”.\begin{equation*} a^2+b^2=c^2 \tag{Pythagoras} \end{equation*}


\begin{equation} E=mc^2 \tag{ फेमस} \end{equation}

\(\begin{equation*} a^2+b^2=c^2 \tag{Pythagoras} \end{equation*}\)


\(\begin{equation} E=mc^2 \tag{ फेमस} \end{equation}\)

Suppressing Equation NumbersWithin `align` or `eqnarray` (though `align` is preferred over `eqnarray`), use `\nonumber` before the `\\` to suppress the number for that specific line.\begin{align} x &= y+z \nonumber \\ a &= b+c \end{align}


\begin{align} f(x) &= (x+1)^2 \\ &= x^2+2x+1 \nonumber \end{align}

\(\begin{align} x &= y+z \nonumber \\ a &= b+c \end{align}\)


\(\begin{align} f(x) &= (x+1)^2 \\ &= x^2+2x+1 \nonumber \end{align}\)

All right reserved – © 2025 innovation.word – https://innovation.world – Can be reproduced only with attribution and a link to this page.

Observação: this post focuses only on math equations with LaTeX. It does not illustrate all the possibilities of LaTeX such as document specifications, page management  and formatting, bibliography management, version Control, incorporating internal and external references …

Bonus #1: pitfalls when mixing LateX & HTML or pitfalls when mixing programming languages

This common mistakes come mostly from escaping or not escaping special characters in one language that are understood differently in the other one. Our 12 best Tip:

  1. Not escaping LaTeX special characters: forgetting that characters like \, {, }, ^, _, $, &, #, % have special meaning in LaTeX. If these are part of your data being inserted into a LaTeX string (e.g., from a variable), they must be escaped (e.g., \%, \_, \textasciicircum).
  2. Not escaping HTML/programming language special characters: conversely, if LaTeX code is being embedded as a string within HTML or a linguagem de programação, you might need to escape characters special to that language (e.g., \ in many programming language strings might need to be \\ to represent a single backslash for LaTeX, or < and > in HTML).
  3. Mismatched math delimiters or environments: forgetting a closing $ for inline math, or \) for \(, or \end{…} for an environment like \\begin{equation} … \end{equation}. This is very common when generating LaTeX programmatically.
  4. Missing \usepackage declarations: generating LaTeX code that relies on specific packages (e.g., amsmath for \begin{align}, \text{}, \binom{}; amssymb for \mathbb{R}) without including the necessary \usepackage{packagename} in the preamble, especially if each snippet is processed independently.
  5. Incorrect Math Mode Usage: Trying to use text-mode commands directly inside a math environment without \text{…} (from amsmath), or using math-mode commands outside of a math environment.
  6. Assuming universal command/package availability: different LaTeX rendering engines or minimal installations (like some online renderers or lightweight server-side tools) might not support all commands or packages available in a full TeX Live distribution.
  7. Ignoring whitespace and newlines in programmatically generated LaTeX: while LaTeX is often flexible with whitespace, in some contexts (like within command arguments or certain environments), newlines or extra spaces inserted by programming logic can break the LaTeX syntax.
  8. Overlooking client-side vs. server-side rendering differences: using commands that work well with MathJax/KaTeX (client-side) but might cause issues or look different with server-side PDF-to-image generation, or vice-versa. For example, some complex layout macros might behave differently.
  9. Not handling errors from LaTeX processors: if the generated LaTeX has an error, the rendering might fail silently or produce cryptic HTML output if error messages from the LaTeX compilador (or MathJax/KaTeX) are not captured and handled by the integrating programming language.
  10. Not using raw strings for LaTeX in programming languages: many programming languages interpret backslashes in strings. For LaTeX code, which uses backslashes extensively, it’s often better to use raw string literals (e.g., r”\frac{a}{b}” in Python) to avoid needing to double-escape every backslash (e.g., “\\frac{a}{b}”).
  11. Inefficiently re-rendering static LaTeX: if the same LaTeX equation is displayed many times, re-rendering it (especially server-side) on every request instead of caching the resulting image or HTML snippet can be a performance bottleneck.
  12. Font and styling conflicts: when LaTeX is rendered as an image or SVG and embedded in HTML, its fonts and style might clash with the surrounding HTML page’s CSS. Ensuring consistency or graceful degradation can be tricky.

Bonus #2: LateX most common additional libraries

Latex libraries
Essential latex packages for advanced document design and presentation in engineering and science.
  • amsmath: this is a fundamental package from the American Mathematical Society (AMS) that provides a wide range of features for typesetting advanced mathematical formulas. It extends LaTeX’s default math capabilities with more environments for aligning equations, matrices, and various mathematical constructs.
  • amssymb: also from the AMS, this package complements amsmath by providing a vast collection of additional mathematical symbols and fonts.
  • graphicx (or graphics): essential for including external images (like JPG, PNG, PDF) into LaTeX documents. It allows for scaling, rotation, and other manipulations of graphics.
  • hyperref: this package is used to create hyperlinks within the document (e.g., for table of contents, citations, URLs) and in the resulting PDF.
  • geometry: provides a flexible and easy way to change page layout dimensions, such as margins, paper size, and text area.
  • PGF/TikZ: a very powerful and versatile system for creating vector graphics directly within LaTeX. TikZ is the user-friendly syntax layer for PGF. It’s used for diagrams, charts, and complex illustrations.
  • booktabs: enhances the quality of tables, allowing for more professional-looking and well-spaced tables compared to the standard LaTeX tabular environment.
  • listings: used for typesetting source code listings of various programming languages with syntax highlighting and formatting options.
  • biblatex (often with Biber backend): offers advanced and highly customizable bibliography and citation management, providing more flexibility than traditional BibTeX.
  • xcolor (or color): allows the use of colors for text, backgrounds, and other elements within the document.
  • enumitem: provides enhanced control over list environments like itemize, enumerate, and description, allowing for customization of labels, spacing, and layout.
  • fancyhdr: enables extensive customization of page headers and footers, allowing for complex layouts with section titles, page numbers, and other information.

Conclusão

LaTeX stills stands out as the main tool in the creation of meticulously formatted science and technical documents, especially in fields that demand accuracy and clarity. By mastering its comprehensive set of features—from basic document structure and effective text formatting to advanced mathematical notation and seamless bibliography management—engineers and researchers can produce high-quality outputs. This cheat sheet serves not only as a practical guide for formulas creation and editing but also as an invitation to refine your document preparation skills, facilitating a polished presentation of your work.

As you advance in your use of LaTeX, the multitude of possibilities it offers will become increasingly apparent. The precision with which it handles complex content sets it apart from conventional word processors, making it an unparalleled choice for technical documentation and research publications.

 

Frequently Asked Questions

What is LaTeX and what are its advantages over WYSIWYG editors?

LaTeX is a typesetting system commonly used for producing technical and scientific documents. Unlike WYSIWYG editors, LaTeX separates content from layout, allowing for precise control over document formatting.
 

What is the basic document structure of a LaTeX file?

A LaTeX document typically consists of a preamble and a document body. Common commands included in the preamble are documentclass for specifying the document type and usepackage for importing additional packages.
 

How do I format text in LaTeX?

Text formatting in LaTeX can be achieved using commands like textbf for bold, textit for italics, and underline for underlining text. Additionally, font sizes and styles can be customized using specific size commands such as small and large.
 

What are the methods for typesetting mathematical expressions in LaTeX?

Mathematical expressions can be included in LaTeX either inline or in display mode. Common symbols and structures, such as fractions, roots, sums, integrals, and matrices, have dedicated commands that enable users to format them
accurately. This cheat-sheet is dedicated to that.
 

How can I include figures and tables in a LaTeX document?

Figures and tables can be inserted using commands like “includegraphics” for images and the tabular environment for tables. It’s also possible to add captions and labels for cross-referencing throughout the document.
 

How does bibliography management work in LaTeX?

LaTeX uses BibTeX or similar tools for managing bibliographies and citations. Users can insert references easily using commands like cite and produce a formatted bibliography automatically at the end of the document.
 

What types of documents are commonly produced using LaTeX?

LaTeX can be used to produce various types of documents including journal articles, theses, dissertations, and conference papers and research publications. It is particularly effective for technical documentation that incorporates complex mathematical content or multilingual requirements.

 

Tópicos relacionados

      • Presentation Creation: using Beamer class for creating professional presentations and slideshows.
      • Handling Different Languages: using packages for multilingual typesetting and language-specific features.
      • Appendices and Glossaries: including additional information sections and glossaries in LaTeX documents.
      • Advanced Mathematical Formatting: utilizing advanced features for intricate mathematical notations and formatting.
      • Converting LaTeX to Other Formats: methods for exporting LaTeX documents to HTML, RTF, or other file types.
      • Integration with Version Control: using version control systems to manage revisions of LaTeX documents collaboratively.
      • Error Handling and Debugging: strategies for troubleshooting and fixing common errors encountered in LaTeX documents.
      • Creating High-Quality Graphics: generating and including complex graphics using TikZ or PGF packages.

Tópicos abordados: LaTeX, composição tipográfica, preparação de documentos, notação matemática, gerenciamento de citações, bibliografias, formatação, classes de documentos, pacotes, referências cruzadas, matemática embutida, exibição de matemática, expressões matemáticas, personalização, colaboração, padrões tipográficos, controle de versão e TikZ.

Contexto histórico

1650
1650
1672
1687
1687
1738
1750
1600
1650
1650
1678
1687
1687
1738
1750

(Caso a data seja desconhecida ou irrelevante, por exemplo, "mecânica dos fluidos", é fornecida uma estimativa aproximada de seu surgimento notável)

Imagens em tamanho real e downloads estão disponíveis apenas, 100% gratuitos, para membros registrados.