Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

LaTeX

LaTeX is a programming language layout used to create scientific and academic documents with precision. Its command-based syntax is reminiscent of the approach of the automation of the IT infrastructure (IAC) used by DevOps. As the IAC makes it possible to describe and manage the infrastructure of reproducible way via code, LaTeX offers similar control over the presentation of documents, allowing coherent and efficient management of complex elements such as mathematical equations and references bibliographic.

Why LaTeX?

As DevOps we like to master code generation, deployment generation, document generation. This is why that LaTeX can be a good tool in replacement for Office or LibreOffice.

Without a special editor, coding a LaTeX document is much easier to read an Office/LibreOffice document that is saved in format Office Open XML LaTeX is mainly

Personally, although you can write LaTeX documents with a editor like TeXstudio, it is also possible to use simpler editors such as Nano or Vim. For my part, I use my own IDE, based on Vim, which not only allows you to edit, reformat, linter and view files LaTeX documents, but also, thanks to Nix, to download LaTeX packages.

Vim latex editor
Vim latex editor

The basics

The preamble

The preamble allows you to configure the form of your document and to indicate the additional packages to download as well as their configuration.

the preamble is inserted between the start of the document and the command \begin{document}, it allows you to define the global configurations of the document, such as the document class, the packages to use, and the metadata.

Here is a simple example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
% Define document type and format
% available class :article, report, book, letter, beamer
\documentclass[twocolumn, a4paper, 12pt]{article}
\usepackage[left=0.5in, right=0.5in]{geometry}

% Use french babel
\usepackage{french}

% generate a lipsum paragraph
\usepackage{lipsum}

% Set the title and author
\title{\Huge Document sample}
\author{Bruno Adelé}
\date{5 mai 2024}

%allow underfull vbox (allow empty space at the bottom of the page
\raggedbottom

% Set the space between paragraphs
\parskip=5pt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle

\lipsum[1-2]
\lipsum[6-7]

\end{document}
simple example
simple example (auto-generated with just doc-generate-tex-sample command)

The sections

Sections and subsections in LaTeX are used to organize a document into parts and sub-parts, similar to the structuring by titles in Office. In Additionally, it is possible to generate a table of contents using the command \tableofcontents. Additionally, it is possible to include sections not numbered in the table of contents by adding an asterisk as a suffix (section*{Title}).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
% Define document type and format
% available class :article, report, book, letter, beamer
\documentclass[a4paper, 12pt]{article}

\listfiles

% Use french babel
\usepackage{french}

% generate a lipsum paragraph
\usepackage{lipsum}

% Set the title and author
\title{\Huge Sections list}
\author{Bruno Adelé}
\date{}

%allow underfull vbox
\raggedbottom

% Set the space between paragraphs
\parskip=5pt


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle
\tableofcontents

\section{Section}
\lipsum[1][-2]

\subsection{Subsection}
\lipsum[2][-2]

\subsubsection{Subsubsection}
\lipsum[3][-2]

\subsubsection*{Section without counter}
\addcontentsline{toc}{section}{Section without counter}
\lipsum[4][-2]

\begin{appendix}
	\addtocontents{toc}{\setcounter{tocdepth}{2}}
	\section{Annexes}
	% \addcontentsline{toc}{section}{Annexes}
	\subsection{Liste des ilustrations}
	\listoffigures
	\listoftables
\end{appendix}

\end{document}
section example
section example (auto-generated with just doc-generate-tex-sample command)

Text style

Here is a range of text styles.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
% Define document type and format
% available class :article, report, book, letter, beamer
\documentclass[a4paper, 12pt]{article}

% Use french babel
\usepackage{french}

% generate a lipsum paragraph
\usepackage{lipsum}

% Set the title and author
\title{\Huge Sections list}
\author{Bruno Adelé}
\date{}

\newcommand{\showsize}[1]{\csname #1 \endcsname $\setminus$#1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\section{Sizes}
\noindent \showsize{tiny}
\showsize{scriptsize}
\showsize{footnotesize}
\showsize{small}
\showsize{normalsize}
\showsize{large}
\showsize{Large}
\showsize{LARGE}
\showsize{huge}
\showsize{Huge}

\section{Styles}
\noindent \textnormal{textnormal} \emph{emph} \textrm{textrm} \textsf{textsf} \texttt{texttt} \textup{textup} \textit{textit} \textsl{textsl} \textsc{textsc} \\
\uppercase{uppercase} \textbf{textbf} \textmd{textmd}

\end{document}
textsize example
textsize example (auto-generated with just doc-generate-tex-sample command)

Some tips

Debug

In the Preamble

draf, showframe

LaTeX is a tool that aims to produce optimal formatting for documents, but when it encounters rules that it cannot apply, it generates warnings or errors. However, these error messages can sometimes be difficult to understand. To resolve these problems, it is possible enable a debug mode that provides additional information for understand and correct errors.

By adding the draft and showframe options to the \documentclass command, you can display the borders of the boxes as well as turn the boxes black problem parts.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
% Define document type and format
% available class :article, report, book, letter, beamer
\documentclass[draft, showframe, twocolumn, a4paper, 12pt]{article}
\usepackage[left=0.5in, right=0.5in]{geometry}

% Use french babel
\usepackage{french}

% generate a lipsum paragraph
\usepackage{lipsum}

% Set the title and author
\title{\Huge Document sample}
\author{Bruno Adelé}
\date{5 mai 2024}

%allow underfull vbox (allow empty space at the bottom of the page
\raggedbottom

% Set the space between paragraphs
\parskip=5pt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle

\lipsum[3-5]
\lipsum[12]


\end{document}

debug example
debug example (auto-generated with just doc-generate-tex-sample command)
listfiles

To list the installed packages, simply add the command \listfiles in the preamble, during the next compilation via pdflatex you will have command output the list of files.

 *File List*
 article.cls 2023/05/17 v1.4n Standard LaTeX document class
  size12.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
  french.sty 2019/09/06 The e-french package /V6,11/
     msg.sty 2019/01/01 loading localization extension (V0.51).
latexsym.sty 1998/08/17 v2.2e Standard LaTeX package (lasy symbols)
fenglish.sty 2004/06/23 english interface for the french(le/pro) package
  lipsum.sty 2021-09-20 v2.7 150 paragraphs of Lorem Ipsum dummy text
l3keys2e.sty 2024-02-18 LaTeX2e option processing using LaTeX3 keys
   expl3.sty 2024-02-20 L3 programming layer (loader)
l3backend-pdftex.def 2024-02-20 L3 backend support: PDF output (pdfTeX)
  lipsum.ltd
   t1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
  french.cfg
   ulasy.fd 1998/08/17 v2.2e LaTeX symbol font definitions
 *****

Miscellaneous