This document gives an introduction on how to use LaTeX-style document preparation for creating documentation on this website. LaTeX (stylized as LATEX) is a convenient tool for creating professional looking layouts of documents such as reports, articles, books and more. It is especially convenient for academic use and with documents that contain equations. Furthermore, when writing a LATEX document, the author only works in a plain text file with no formatting so it is very portable and shareable. Platforms exist for collaborative writing online such as Overleaf.
In it’s basic form, LATEX converts text in a plain text file to a PDF document based on various formatting settings. These settings are given directly in the plain text document. For this website, a script exists to translate the LATEX output to HTML for displaying in a web browser.
The base LATEX →HTML translation is done using tex4ht. However, the script heavily modifies both the input and output to the base translator in order to produce the appearance shown on this website. The website is meant to be an easy-to read ”Wiki”-style environment.
The script also creates a PDF using the standard pdflatex command. The PDF and the web page (bearing exactly the same content) automatically reference each other with hyperlinks.
As a result, at the top of this document, there will be a link to the corresponding PDF(when viewing the website) or URL(when viewing the PDF). Click it to compare!
Creating documentation for this website is done, for the most part, with regular LATEX without modification. However, in order to work with the conversion script, a few custom additions and rules are needed. Those relating to the general document are detailed below. For the document content, see subsequent sections relating to adding content.
Two methods/platforms are currently available for creating and editing articles for this website.
Certain commands shall precede the \begin{document}-marker in order to properly link it to the website and the author’s profile.
The \documentID is used to identify this document on the website. It can be set to anything (alphanumeric) but it may be useful to set it to relate to the contents somehow. This document is named ”latex2web” for example. The \authorID should match the author’s ID on the website members page since the document will automatically be given a link to the author’s profile there. The \date{\today} command should be left as it is, it will automatically show the date the document was created (compiled) as the publication date. If a different publication date is desired, it can be modified accordingly.
The \fileInclude command can be used to attach files to the document. The attachment should be placed in the attachments-folder as shown in Section 2.3.
The LATEX source file, attachments and figure images shall be placed in a certain folder structure as shown in Fig. 1. A template document with the correct structure is attached to this document. The root folder and LATEX source file can be called anything but it may be useful to name them according to the \documentID discussed above.
Code (such as C++, bash, python etc.) can be displayed in using the LATEX lstlisting environment. This is used in the LATEX code as :
For example, if one pastes some C++ code as shown above, it produces the following in the document:
Tables and figures are created with the standard \begin{table}...\end{table} and \begin{figure}...\end{figure} environments respectively. Add the [h!] option to prevent them from free floating in the PDF. There is no floating in the HTML by default. Adding a \label{<some name>} tag inside these environments allows for cross-referencing. For example, to create a table with a caption and a hyperlink to reference it :
which produces Table 1.
Figures are created similarly as:
which produces Fig. 2. The images should be placed in the images-folder as shown in Section 2.3.
LATEX is a useful program for writing documents containing equations. This document supports two types of equations, inline and block.
Inline equations appear directly in the text. For example: ”the velocity in the -direction is defined as ”. To create an inline equation, please use tag \ieq. Using the custom tag \ieq over any other ways to define a math environment ensures that the equation is given proper alignment in the HTML. Example definitions of inline equations are given in Table 2.
Block equations are put in their own separate space and given an equation number. Use the standard \begin{equation}...\end{equation} environment to define block equations. Adding a \label{<some name>} tag inside this environment allows for cross-referencing. For example, to create an equation and create a hyperlink to reference it :
which produces Eq. (1). The equation reference to Eq. (1) is created as: \eqref{example_eqn}.
| (1) |
In the PDF, long equations will automatically be broken up onto multiple lines using the breqn package and the dmath environment. The equation environment will automatically be changed to dmath when compiling the PDF.
For the HTML output, using breqn is not possible. Therefore, locations of where the equation should break need to be defined by manually. This is done with the custom \mainflexsplit and \secondaryflexsplit commands. The equation will be broken up onto different lines at the location where these are inserted. For narrower screens, such as tablets, the equation will be broken at \mainflexsplit. For even narrower screens, such as smartphones, the equation will be broken at \secondaryflexsplit and \mainflexsplit. These splits have no effect for the PDF compilation where equations will be broken up automatically using breqn.
For example, Eq. (2) is a pretty long equation that is probably fine to display on one line on desktops and tablets, but needs to be broken up onto two lines to display nicely on smartphones. It is created as:
and displays as:
| (2) |
Eq. (3) is an even longer equation that needs to be split into two lines for tablets and into multiple lines for smartphones. It is created as:
and displays as:
| (3) |
References can be added using the standard \cite and \citep commands together with a bibliography stored in a .bib-file (see Section 2.3). The bibliography is added to the document using \bibliography{bibfilename}, where bibfilename is the name of the .bib-file without the .bib extension. The bibliography will appear the location where this command is given in the LATEX source file.
For example. By adding the following to a file called latex2web.bib:
this book can be cited as:
which results in:”LATEX was created by Lamport (1986).” The reference also shows up in the bibliography (created as: \bibliography{latex2web}) automatically.