Everybody can use LaTeX

LaTeX for the rest of us

Using LaTeX as a document authoring tool is beneficial even if you never use equations. Actually, if you do not use equations or sophisticated page layout, it is very simple! LaTeX is especially useful if:

  • your document has a hierarchical structure, featuring sections, subsections etc…
  • there are lots of cross-references in the document, meaning that you often mention some part of the document within another part of the document.

Moreover, using LaTeX2Web lets you publish your document into a mobile-friendly web page.

Most of the content in a LaTeX document is just plain text. LaTeX2Web natively supports non-English characters, such as Latin accented characters, Cyrillic text, and text in many other language systems. Paragraphs are created when encountering a blank line.

The rest of LaTeX consists of LaTeX commands and LaTeX environments. Environments are specialized commands that mark the beginning and the end of content blocks that have special meaning, depending on the name of the environment.

Before going on, check if you know how to type a backslash \ character on your keyboard, because it is used all the time in LaTeX.

The structure of LaTeX commands

If you use just plain text (with multibyte encoding in LaTeX2Web), just type your text and you are good to go. Paragraphs are created each time a blank line is encountered.

Beyond this, you will have to use LaTeX commands. A LaTeX command is built with the following contiguous components:

  • the command name: the command name is characterized by the fact that it begins with a backslash \ character. So you will use this character often in a LaTeX document.
  • optional parameter(s): each optional parameter is enclosed in brackets: [optional parameter]. Since these parameters are optional, they can be omitted in the command.
  • mandatory parameter(s): each parameter is enclosed in curly braces: {mandatory parameter}

    As a summary, here is pseudocode that represents a valid LaTeX command structure:

    \name[optional]{mandatory}
    

Sectioning commands

The sectioning commands define the structure of your document. There are 7 of them, going from the highest level to the lowest one:

  • \part
  • \chapter
  • \section
  • \subsection
  • \subsubsection
  • \paragraph
  • \subparagraph

\part and \chapter should be used only in long documents, like a memoir or a book.

Each sectioning command has one mandatory parameter, which is the title of the section. The title may include LaTeX code. If a star * character is added at the end of the sectioning command, the section will not be numbered. Here is an example of a sectioning command: latex \section{Introduction}

In print, the sectioning commands are only used to produce a title with specific formatting. In LaTeX2Web, they first class citizens. They do not only create titles, but they also have content. LaTeX2Web documents are thus explicitly organized hierarchically.

Cross-references

LaTeX is especially good at referencing content. This is done in two steps.

Create the label

First, a label is attached to the content that should be referenced. This label must be unique in order for the reference to work. It is created using the \label command. For instance, the following code:

\section{Introduction}\label{introductionSection}

will attach the introductionSection label to the introduction.

The parameter of the \label command is the name of the label.

Reference the content

To reference content, you use the \ref command, its (mandatory) parameter being the name of the label. The command can be used in any text content.

Here is a usage example:

As we said in the introduction \ref{introductionSection}, .....

What will happen then? It depends on how you use LaTeX.

  • in print, the \ref command produces the number attached to the content. For instance, if the introduction is the first section, the command will put the number 1 in the flow of the text. This gives: As we said in the introduction 1, ......
  • in PDF, the \ref command also inserts the number 1, but clicking on the number will bring focus to the introduction.
  • In LaTeX2Web, when you click on the number 1, the content (here the introduction) is displayed as close as possible to the referencing text. This way, you both see the referencing and the referenced content.

Paragraph/inline content

While sections define the hierarchy of a document, inline content is the basic building block of document content. Inline content is essentially text with some possible variations.

Environments, that we shall discover later on, are blocks of content, which do not wrap along the vertical limits of the document. Environments may include inline text, but the converse is false.

Text styling

There are eight text styling command, which can also be viewed as a change in font usage. The commands have a two letter name and the parameter is the text to which the styling should be applied. Here is a table.

Command Style
\rm Roman, i.e. normal text
\em Emphasized, used for true italics
\bf Bold
\it Italic, see \em
\sl Slanted, aka false italics
\sf Sans Serif
\sc Small Capitals
\tt Monospace (\tt stands for typewriter)

Paragraphs

Paragraphs consist of inline text that stands between two blocks of empty lines. One blank line can be omitted if the paragraph is at the beginning or end of a section or environment.

Other commands for inline text

Footnotes

The LaTeX command

\footnote{content}

will produce a footnote where content can be any inline text.

In print, the footnote is displayed at the bottom of the page. In LaTeX2Web, since there is no kind of page, the footnote is indicated by a speech bubble. The footnote content is revealed by clicking on the bubble.

HTML links

There are two commands to embed HTML links

\href{URL}{displayed text}

will display displayed text as a link to URL.

\url{URL}

is a shortcut for \href{URL}{URL}.

Horizontal separator

\rule

will display a horizontal divider.

Margin note

\marginpar{content}

will display the content as a side note.

Framed text

\fbox{content}

will draw a rectangle border around the content.

Environments

Environments define a scope which, in many cases, is semantically meaningful. If name is the name of the environment, the general syntax for an environment is the following:

\begin{name}
... content ...
\end{name}

Environments are blocks of content that cannot split across lines. In general, environments can be numbered and have a label.

We give now some information about basic environments, from the most general to the most particular. This classification means that environments that precede another environment can content this lower level environment.

Theorems

While theorems are generally part of mathematical content, they are actually general blocks with a special place in the document hierarchy.

Theorems are general purpose containers that can include about anything, except sections and other theorems. Theorems are great to focus on specific content of varied nature, which be used for reference in the rest of the document.

Theorems contain important stuff.

There can be multiple types of theorems, which semantically categorize which kind of content they have.

Theorems typically have a label attached to it.

Theorem definition

A theorem class is defined as follows:

\newtheorem{theoremName}{Displayed name of the theorem}

Usage

Example usage

\begin{theoremName}[optional specific name for this theorem]\label{youShouldUseALabel}
... content ...
\end{theoremName}

The output will typically look like

Displayed name of the theorem 1 .. content ...

If you have specified an optional name for this theorem instance, the result will look like: Displayed name of the theorem 1 (optional specific name for this theorem) .. content ...

Usage example

We define the summary theorem class:

\newtheorem{summary}{Summary}

and we use it like this:

\begin{summary}[Theorems]\label{theoremSummary}
Theorems are general purpose container that can include about anything, except sections and other theorems. Theorems are great to focus on specific content of varied nature, which be used for reference in the rest of the document. Theorems contain \em{important} stuff.

There can be multiple types of theorems, which semantically categorize which kind of content they have.

Theorems have typically a label attached to it.
\end{summary}

This will yield Summary 1 (Theorems) Theorems are general purpose container that can include about anything, except sections and other theorems. Theorems are great to focus on specific content of varied nature, which be used for reference in the rest of the document. Theorems contain *important stuff.*

There can be multiple types of theorems, which semantically categorize which kind of content they have.

Theorems have typically a label attached to it.

Quotations

there are three environment for quotation like content: quote, quotation and verse. In LaTeX2Web, the three are the same.

The code

\begin{quote}
We must let go of the life we have planned, so as to accept the one that is waiting for us.

Joseph Campbell
\end{quote}

gives

We must let go of the life we have planned, so as to accept the one that is waiting for us.

Joseph Campbell

Lists

Lists are environments that produce ... lists. Lists consist of a succession of items. Items are separated by \item commands. The \item command has no mandatory parameter. It can have an optional parameter, whose value will replace the list item beginning, which is usually a bullet or a number.

Lists can contain other lists (recursivity) and include anything except sections and theorem (hierarchy).

The environment is itemize for un-numbered lists, and enumerate is for numbered lists. For instance,

\begin{itemize}
\item I am the first
\begin{itemize}
\item No, it's me
\end{itemize}
\item I am at the end
\end{itemize}

will yield

  • I am the first
    • No, it's me
  • I am at the end

Tables and tabular

A table environment contains two things * a caption specified by the mandatory argument of a \caption command * the table itself, which is contained in a tabular environment.

We shall not go into the details of the tabular environment syntax, since it is quite complicated. We advise the reader to use the LaTeX2Web specific environment named csv, which imports a CSV (produced by Excel, for instance) directly into the web page.

Figure and images

A figure environment contains two things

  • a caption specified by the mandatory argument of a \caption command
  • an \includegraphics command, whose mandatory parameter specifies the location of the image.

The location can point to a local graphic file (which typically has been uploaded as part of the document project). Additionally, in LaTeX2Web , the location may consist in a valid URL which points to the graphic file on the internet.

Here is an example code for a remote image:

\begin{figure}\label{remoteImage}
\includegraphics{https://www.dropbox.com/scl/fi/zm0i4nqqd63ughip9a64l/old-press-printing-machine-2023-11-27-05-34-50-utc.jpg?rlkey=vbyeznilb16hww8kmafmyriz9&raw=1}
\caption{A printing machine}
\end{figure}

The image files must be in one of the following formats

  • png
  • jpg
  • gif (included animated gif)
  • svg

Tags
Year

Year / Month

Authors

Index
Archive