build details

Show: section status errors & todos local changes recent changes last change in-page changes feedback controls

Using LaTeX constructs in documentation

Modified 2019-09-22 by Andrea Censi

Working knowledge of LaTeX.

Embedded LaTeX

Modified 2019-09-22 by Andrea Censi

You can use \LaTeX math, environment, and references. For example, take a look at

x^2 = \int_0^t f(\tau)\ \text{d}\tau

or refer to Proposition 1 - Proposition example.

Proposition example This is an example proposition: 2x = x + x .

The above was written as in Listing 3.1.


You can use $\LaTeX$ math, environment, and references.
For example, take a look at

\[
    x^2 = \int_0^t f(\tau)\ \text{d}\tau
\]

or refer to [](#prop:example).

\begin{proposition}[Proposition example]\label{prop:example}
This is an example proposition: $2x = x + x$.
\end{proposition}

Use of LaTeX code.

For the LaTeX environments to work properly you must add a \label declaration inside. Moreover, the label must have a prefix that is adequate to the environment. For example, for a proposition, you must insert \label{prop:name} inside.

The following table shows the list of the LaTeX environments supported and the label prefix that they need.

LaTeX environments and label prefixes
definition def:name
proposition prop:name
remark rem:name
problem prob:name
theorem thm:name
lemma lem:name

Examples of all environments follow.

\begin{definition}[My definition]   \label{def:lorem}
Lorem
\end{definition}

My definitionLorem

\begin{proposition}[My proposition]   \label{prop:lorem}
Lorem
\end{proposition}

My propositionLorem

\begin{remark}[My remark]   \label{rem:lorem}
Lorem
\end{remark}

My remarkLorem

\begin{problem}[My problem]    \label{prob:lorem}
Lorem
\end{problem}

My problemLorem

\begin{example}[My example]   \label{exa:lorem}
Lorem
\end{example}

My exampleLorem

\begin{theorem}[My theorem]   \label{thm:lorem}
Lorem
\end{theorem}

My theoremLorem

\begin{lemma}[My lemma]   \label{lem:lorem}
Lorem
\end{lemma}

My lemmaLorem

I can also refer to all of them:
[](#def:lorem),
[](#prop:lorem),
[](#rem:lorem),
[](#prob:lorem),
[](#exa:lorem),
[](#thm:lorem),
[](#lem:lorem).

I can also refer to all of them: Definition 1 - My definition, Proposition 2 - My proposition, Remark 1 - My remark, Problem 1 - My problem, Example 1 - My example, Theorem 1 - My theorem, Lemma 1 - My lemma.

LaTeX equations

Modified 2018-06-02 by Andrea Censi

We can refer to equations, such as \eqref{eq:one} :

\begin{equation} 2a = a + a \label{eq:one}\tag{1} \end{equation}

This uses align and contains \eqref{eq:two} and \eqref{eq:three} .

\begin{align} a &= b \label{eq:two}\tag{2} \\ &= c \label{eq:three}\tag{3} \end{align}

We can refer to equations, such as \eqref{eq:one}:

\begin{equation}
    2a = a + a          \label{eq:one}
\end{equation}

This uses `align` and contains  \eqref{eq:two} and \eqref{eq:three}.

\begin{align}
    a &= b       \label{eq:two} \\
      &= c       \label{eq:three}
\end{align}

Note that referring to the equations is done using the syntax \eqref{eq:name}, rather than [](#eq:name).

LaTeX symbols

Modified 2018-09-22 by Andrea Censi

You can place any LaTeX symbols definition in files called *.symbols.tex.

These will be included as preamble.

For example, this repository contains a file a.symbols.tex containing:

\newcommand{\mysymbol}{\text{This is defined in a.symbols.tex}}

So then when we create an equation with:

$$ \mysymbol $$

It gets rendered as:

\mysymbol

Bibliography support

Modified 2020-09-04 by Andrea Censi

You need to have installed bibtex2html.

The system supports Bibtex files.

Place *.bib files anywhere in the directory.

Then you can refer to them using the syntax:

[](#bib:bibtex ID)

For example:

Please see [](#bib:siciliano07handbook).

Will result in:

Please see [1].

Somewhere in the document, add the following:

<div id="put-bibliography-here"></div>

Embedding Latex in Figures through SVG

Modified 2019-09-21 by Andrea Censi

In order to compile the figures into PDFs you need to have Inkscape installed. Instructions to download and install Inkscape are here.

To embed latex in your figures, you can add it directly to a file and save it as filename.svg file and save in the /docs directory in a subfolder called assets/svg2pdf.

You can then run:

$ make process-svg-figs

And the SVG file will be compiled into a PDF figure with the LaTeX commands properly interpreted.

You can then include the PDF file in a normal way (Section 1.6 - Figures) using filename.pdf as the filename in the <img> tag.

Image saved as svg
Image as PDF after processing
Embedding LaTeX in images

It can take a bit of work to get the positioning of the code to appear properly on the figure.

Using the HTML equivalent of Latex environments

Modified 2019-09-22 by Andrea Censi

You can create an exercise as follows:

<div id="exercise:my-exercise" class="exercise" title="Exercise title">
    This is an exercise labeled "exercise:my-exercise". 
</div>

<div class="exercise" title="Second exercise">
    This is an exercise not labeled. 
</div>

Referring to the exercise: [](#exercise:my-exercise) or [](#my-exercise).
This is an exercise labeled "exercise:my-exercise".
This is an exercise not labeled.

Referring to the exercise: Exercise 1 - Exercise title or Exercise 1 - Exercise title.

Alternative style

Modified 2019-09-22 by Andrea Censi

If you have block content element (e.g. code blocks), you must use headers as html cannot contain block-level Markdown.

You must use somethign like the following. The marker end tells the system to stop the level 4 section.

#### Another exercise {#exercise:another}

This is another exercise with block content:

    $ echo hello

<end/>

This is part of the level 2 section.

Another exercise starts for the rest of the section.

#### Another exercise {#exercise:second}

contents

<end/>

After the second exercise.

Another exercise

This is another exercise with block content:

$ echo hello

This is part of the level 2 section.

Another exercise starts for the rest of the section.

Another exercise

contents

After the second exercise.