mention typewriter font in LaTeX guide

This commit is contained in:
PgBiel 2025-03-04 17:58:59 -03:00
parent c4d7faf527
commit 25ad4f7d41

View File

@ -75,21 +75,23 @@ Emphasis (usually rendered as italic text) is expressed by enclosing text in
Here is a list of common markup commands used in LaTeX and their Typst
equivalents. You can also check out the [full syntax cheat sheet]($syntax).
| Element | LaTeX | Typst | See |
|:-----------------|:--------------------------|:-----------------------|:-----------|
| Strong emphasis | `\textbf{strong}` | `[*strong*]` | [`strong`] |
| Emphasis | `\emph{emphasis}` | `[_emphasis_]` | [`emph`] |
| Monospace / code | `\texttt{print(1)}` | ``[`print(1)`]`` | [`raw`] |
| Link | `\url{https://typst.app}` | `[https://typst.app/]` | [`link`] |
| Label | `\label{intro}` | `[<intro>]` | [`label`] |
| Reference | `\ref{intro}` | `[@intro]` | [`ref`] |
| Citation | `\cite{humphrey97}` | `[@humphrey97]` | [`cite`] |
| Bullet list | `itemize` environment | `[- List]` | [`list`] |
| Numbered list | `enumerate` environment | `[+ List]` | [`enum`] |
| Term list | `description` environment | `[/ Term: List]` | [`terms`] |
| Figure | `figure` environment | `figure` function | [`figure`] |
| Table | `table` environment | `table` function | [`table`] |
| Equation | `$x$`, `align` / `equation` environments | `[$x$]`, `[$ x = y $]` | [`equation`]($math.equation) |
| Element | LaTeX | Typst | See |
|:-----------------------|:--------------------------|:-----------------------|:-----------|
| Strong emphasis | `\textbf{strong}` | `[*strong*]` | [`strong`] |
| Emphasis | `\emph{emphasis}` | `[_emphasis_]` | [`emph`] |
| Link | `\url{https://typst.app}` | `[https://typst.app/]` | [`link`] |
| Label | `\label{intro}` | `[<intro>]` | [`label`] |
| Reference | `\ref{intro}` | `[@intro]` | [`ref`] |
| Citation | `\cite{humphrey97}` | `[@humphrey97]` | [`cite`] |
| Verbatim / code | `\verb|print(f"{x}")|`, `verbatim` / `listing` environments | ``[`print(f"{x}")`]`` | [`raw`] |
| Monospace / typewriter | `\texttt{mono}` | ``[`mono`]`` or `text` function | [`raw`], [`text`] |
| Verbatim | `verbatim` environment | ``[`#typst-code()`]`` | [`raw`] |
| Bullet list | `itemize` environment | `[- List]` | [`list`] |
| Numbered list | `enumerate` environment | `[+ List]` | [`enum`] |
| Term list | `description` environment | `[/ Term: List]` | [`terms`] |
| Figure | `figure` environment | `figure` function | [`figure`] |
| Table | `table` environment | `table` function | [`table`] |
| Equation | `$x$`, `align` / `equation` environments | `[$x$]`, `[$ x = y $]` | [`equation`]($math.equation) |
[Lists]($list) do not rely on environments in Typst. Instead, they have
lightweight syntax like headings. To create an unordered list (`itemize`),
@ -121,6 +123,16 @@ To get a [numbered list]($enum) (`enumerate`) instead, use a `+` instead of the
hyphen. For a [term list]($terms) (`description`), write `[/ Term: Description]`
instead.
Regarding the usage of monospace fonts (also known as "typewriter" font style
in LaTeX), it should be noted that using [`raw`] such as in
``[`monospace`]`` (where you'd use `\texttt{monospace}` in LaTeX) works for
most cases where you only have simple text. If you need to use formatting, such
as in `\texttt{monospace \textbf{bold}}`, you will need to replicate its look by
switch to changing the text font to a monospace font with
`#text(font: "DejaVu Sans Mono", size: 0.8em)[monospace *bold*]`, for example,
since `raw` only supports verbatim (unformatted) text. See its documentation
for more details.
## How do I use a command? { #commands }
LaTeX heavily relies on commands (prefixed by backslashes). It uses these
_macros_ to affect the typesetting process and to insert and manipulate content.