LaTeX

In this page there is a LaTeX guide in Spanish (check Librería for a one file version) and some tips and curiosities in English.

LaTeX guide (Spanish)


Tips and curiosities

In the examples it is assumed a minimal header including the basic mathematical packages amsmath, amsfonts and amssymb. Namely, the examples have been tested with

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

When extra packages are needed, it is explicitly indicated.

Tags: alignment, arrays, arrows, beamer, bibliography, boxes, footnotes, packages, page, paragraphs, spanish, summation, table of contents, templates, types.


Alignment: Odd centering
The command \stretch(<n>) indicates an undetermined length proportional to n. This can be used in combination with \hspace to center the content of a line or a box as in this example:
\hspace{\stretch{1}}Centered text\hspace{\stretch{1}}
Of course the standard way is the environment center but \stretch offers the possibility of some odd centering. For instance,
\hspace{\stretch{2}}Centered text\hspace{\stretch{1}}
leaves double space to the left. Another example combining center and \stretch is:

\

\vspace{\stretch{1}}
\begin{center}
For a page title
\end{center}
\vspace{\stretch{3}}
\pagebreak
It centers the text horizontally and also vertically leaving three times less space in the top part. The initial blank line is to force the vertical mode. Otherwise, \vspace does not work.
Arrays: maximum number of columns
By default, the maximum number of columns is 10. This number can be modified changing the counter MaxMatrixCols. For instance,
\setcounter{MaxMatrixCols}{11}
\[
  \begin{pmatrix}
  1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11
  \end{pmatrix}
\]
The error message when MaxMatrixCols is exceeded is strange: Extra alignment tab has been changed to \cr.
Arrows: long arrows
The length of \longrightarrow is fixed. It causes problems to put text or formula over or under it. For instance:
\[
  A\overset{\text{too long text}}{\longrightarrow}B
\]
\[
  A\underset{\text{too long text}}{\longrightarrow}B
\]
is unsatisfactory. A solution is \xrightarrow[...]{...} where the first argument (optional) gives the upper content and the second argument the lower one. Then the previous examples are repaired with:
\[
  A\xrightarrow{\text{too long text}}B
\]
\[
  A\xrightarrow[\text{too long text}]{}B
\]
There is also a \xleftarrow with similar structure. Using \hspace{...} as one of the arguments one can draw very long arrows. For instance A\xleftarrow{\hspace{200pt}}B.
Without loading packages, there is no analogue for \mapsto and \hookrightarrow. It can be emulated using that \mapstochar and \lhook generate the vertical bar and the hook appearing in these arrows. For instance, we obtain extra large \mapsto and \hookrightarrow with
\[
  A\mapstochar\xrightarrow{\hspace{100pt}}B
  \qquad
  A\lhook\joinrel\xrightarrow{\hspace{100pt}}B
\]
In the second case, \joinrel avoids a small space between the hook and the arrow.
beamer: numbering
Sometimes we are using a theme, for instance Warsaw that does not show the number of the slide by default. In this case, it shows in the footer the short title. To add the number of the slide with minimal changes one can redefine \insertshorttitle adding to its definition the number with a very clever trick taken from here which has broader interest. For the aforementioned problem of numbering, the code to include in the preamble is:
\expandafter\def\expandafter\insertshorttitle\expandafter{%
\insertshorttitle\hfill%
\insertframenumber\,/\,\inserttotalframenumber}
It adds something like n/N flushed to the right.
beamer: shorter blocks
Sometimes in beamer one needs to horizontally align two blocks or putting an image beside a block. The environment columns allows to define columns of different length without loading extra packages in the class beamer. This is an example of its use:
\begin{columns}
  \begin{column}{6cm}
    \begin{block}{This is the left block}
    Content 1
    \end{block}
  \end{column}
\begin{column}{3cm}
    \begin{block}{Right block}
    Content 2
    \end{block}
  \end{column}
\end{columns}
beamer: verbatim
To use the environment verbatim in beamer we must start the slide with \begin{frame}[fragile].
Bibliography: BibTeX entry for arXiv
A possibility for a BibTeX entry for a paper posted in the arXiv is like in this example
@UNPUBLISHED{arXiv:2107.07245,
AUTHOR = {Chamizo, F.},
TITLE = {A simple evaluation of a theta value and the {K}ronecker limit formula},
YEAR = {2021},
NOTE = {arXiv:2107.07245 [math.NT]},
URL = {https://arxiv.org/abs/2107.07245},
}
Bibliography: BibTeX entry for web material
A possibility for a BibTeX entry for contents published in the internet is like in this example
@MISC{chamizo,
AUTHOR = {Chamizo, F.},
TITLE = {A course on signal processing},
YEAR = {2020},
NOTE = {Lecture notes of a master course},
HOWPUBLISHED = {\url{http://matematicas.uam.es/~fernando.chamizo/libreria/fich/signal_processing.pdf}}
}
It is assumed the package url.
Bibliography: BibTeX styles
The following lines are to use BibTeX with a file bibfile.bib getting the references ordered in the standard way (in mathematics) and numbered
\bibliographystyle{plain}
\bibliography{bibfile}
It is also common alpha instead of plain that shows alphabetic labels. There are some other admissible bibliography styles. Many of them are offered by scientific journals and downloadable from their websites. It seems that the standard extra styles provided by the standard BibTeX are abbrv, acm, apalike, ieeetr, siam and unsrt. The results are shown in the Overleaf documentation.
Bibliography: name
The variable \refname contains the name of the Bibliography. For instance "References" in the article style. It can be redefined with \renewcommand. The following example does not change the name but adds a footnote:
\renewcommand{\refname}{References\footnote{In the works authored by Euler we follow Enestrom classification.}}
Boxes: frames
The most used command to draw a frame around a part (sentence, word) of a line is \fbox. The command frame is like \fbox leaving no separation between the content and the frame. It is use to limit images. For \fbox, the variables \fboxrule and \fboxsep store the thickness of the frame and the separation. As usually, with brackets we give a local validity to the changes in these lengths. An example is
This is a {\setlength{\fboxrule}{2pt}\setlength{\fboxsep}{10pt}\fbox{thick frame}} separated a lot.
To make a frame containing several lines, a (probably unorthodox) quick possibility is to put them in a vertical box with \fbox{\vbox{<text>}}. Another possibility is to use the minipage environment in the form \fbox{\begin{minipage}{\textwidth}<text>\end{minipage}}.
The command \framebox is more flexible than \fbox. It has two optional arguments. The first one is the horizontal length of the frame and the second can take the values s, r and l, meaning the alignment spread, right and left. For instance,
This is \framebox[0.5\textwidth][s]{a short text} for a long frame.
spread the three words along a frame taking half a line, causing a severe underfull. By the way, taking the ideas of the "odd centering" discussed above, the three words will appear ccentered in the frame with
This is \framebox[0.5\textwidth][l]{\hspace{\stretch{1}}a short text\hspace{\stretch{1}}} for a long frame.
Boxes: general constructor
The general command to create a box is \makebox[width][position]{text}. If the optional arguments are not used, then it works like \mbox{text}. The position can be c for centered (default), s for spread, r for flushright and l for flushleft. Consider
\makebox[0.5\textwidth][s]{this is the text}

\makebox[0.5\textwidth][s]{this\hfil is\hfil the\hfil text}

\makebox[0.5\textwidth][c]{this is the text}
The first form produce an error Underfull \hbox because the words cannot be spread along half a line without excessive spaces between them. The second form prevents this error. In the third form, the spacing is as usual and the sentence appear centered in the half line.
The length \width is the usual width corresponding to the mandatory argument. For instance, Before\makebox[2\width]{Middle}After assign to Middle double width than usual, leaving extra spacing after and before. Changing 2\width by 0.5\width, the text would overlap with the preceding and next words.
A box of width zero can be useful to introduce text not interfering with the rest and avoiding errors, For instance, with
\noindent\makebox[0em][r]{margin text\ }This paragraph is supposed to take more than a line to see the alignment of the two first lines. There is no indent to make it apparent...
we obtain a margin text to the left of a not indented paragraph.
Boxes: minipage
The environment minipage creates a box with the width indicated in its argument. As the name suggests, this box is a special one which shares some properties with a page, namely it may contain paragraphs, footnotes and itemized lists. A cheap form of including a two-column text in a one-column document is using minipage as in this example:
\noindent
\begin{minipage}{0.49\textwidth}
Minipage behaves a a page inside of a page\footnote{It may contain footnotes} with displayed formulas
\[
1+1=2.
\]

Several paragraphs
\end{minipage}\ \
\begin{minipage}{0.49\textwidth}
It also may content lists with several items
\begin{itemize}
\item One \item Two \item Three
\end{itemize}
\end{minipage}
The environment admits three optional arguments. The first optional argument is c (center, default) t (top) or b (bottom) and indicates the alignment with the surrounding text. For example, with the default option c
Read this $\to$\quad \begin{minipage}[c]{4cm}
Text

of

several

paragraphs
\end{minipage}
the arrow points between "of" and "several", with t it is in front of "Text" and with b, it is in front of bottom. The second optional argument gives the height of the box. It can be used to leave some space after or before minipage. If it is less than the height of the content then part of the text will overlap with the following paragraph but no error is raised. The last optional argument is again c, t or b and indicates the alignment of the content inside the box. For instance, if in the example with two column we replace the second \begin{minipage}{0.49\textwidth} by \begin{minipage}[c][10cm][t]{0.49\textwidth} then there is a lot of space after the columns and the first column appears in a lower vertical position.
Boxes: prevent hyphenation
With \mbox{} a box is created for its argument with the necessary width. It can be used to to prevent hyphenation because the box is kept in the same line.
Boxes: raise
A box can be raised with \raisebox{h}[l1][l2]{} where h is the height to raise and the optional lengths l1 and l2 are used to cheat LaTeX to pretend that the result extends l1 above the base line and l2 below the base line. For instance, with
\raisebox{-4.0pt}{w}\raisebox{4.4pt}{a}\raisebox{8.0pt}{v}%
\raisebox{2.0pt}{e}\raisebox{-7.6pt}{l}\raisebox{-9.8pt}{e}\raisebox{-4.8pt}{t}
we obtain a wavy form of the word "wavelet". In the middle of a paragraph it requires more vertical space and the separation between lines changes accordingly. If we use
\raisebox{0pt}[0pt][0pt]{\raisebox{-4.0pt}{w}\raisebox{4.4pt}{a}\raisebox{8.0pt}{v}%
\raisebox{2.0pt}{e}\raisebox{-7.6pt}{l}\raisebox{-9.8pt}{e}\raisebox{-4.8pt}{t}}
then we cheat LaTeX pretending that no extra space between lines is needed. In this situation, probably part of the curly word will overlap with the preceding and the succeeding line.
Boxes: rules
A rule is a black filled box. The syntax is \rule[opt]{width}{thickness} The width and the thickness are self-explanatory. The optional argument indicates how much it is raised over the baseline. With \rule{0.25\textwidth}{8pt}\rule[-2pt]{0.25\textwidth}{8pt} we get a black line of thickness 8pt along 1/4 of the text width followed by a similar one 2pt below.
It behaves as text and then it is affected by the package xcolor if we want to change color.
Boxes: show boxes
This simple code, which is a simple modification of the second answer here,
\makeatletter
\def\wordboxes#1{%
  \fboxsep=0pt\fboxrule=.1pt%
  \@tfor\xx:=#1\do{%
    \ifx\xx\space{\ }\else\fbox{\phantom{\xx}}\fi}%
}
\makeatother
defines the command \wordboxes{} which shows the boxes associate to a word. It also work for sentences if the spaces are enclosed between brackets. The same rule applies for accents or other composed symbols.
\wordboxes{Hi!}
\wordboxes{Hi There!} % wrong
\wordboxes{Hi{ }There!} % right
\wordboxes{r\^ole} % wrong
\wordboxes{r{\^o}le} % right
The heart of the macro is a \@tfor loop. In this kind of loops the variable takes as values the elements of a list of tokens.
Footnotes: numbering
The usual numbering of the footnotes can be altered indicating the new number as an optional argument of \footnote. For instance
The first sentence\footnote{First note}
The second sentence\footnote[7]{Seventh note}
The third sentence\footnote{Second note}
at the beginning of a document would number the notes as 1, 7 and 2.
To simulate several consecutive calls to the same footnote one can use \footnotemark{\value{footnote}] instead of \footnote after the first call. For instance,
The first sentence\footnote{First block}.
The second sentence\footnotemark[\value{footnote}].
The third sentence\footnote{Second block}.
The fourth sentence\footnotemark[\value{footnote}].
shows: The first sentence1. The second sentence1. The third sentence2. The fourth sentence2. As the previous syntax suggests, footnote is a counter then with \setcounter{footnote}{n} the next footnote will be numbered with n+1.
Footnotes: text in the footer
Sometimes one wants to put some text in the footer without any mark. A solution is to redefine temporarily \thefootnote as an empty string and decrease footnote by one. For instance,
The first sentence\footnote{First}.
{\def\thefootnote{}%
\footnote{First fake note}\addtocounter{footnote}{-1}%
\footnote{Second fake note}\addtocounter{footnote}{-1}}%
The second sentence\footnote{Second}.
In the footer it will appear
1First
First fake note
Second fake note
1Second
Latexdiff
Latexdiff is a script to compare two LaTeX files giving a third file as output. Apparently it can give some poblems with mathematical formulas. Two examples of use are:
latexdiff --math-markup="off" -t CFONT old.tex new.tex > diff.tex
and
latexdiff --math-markup="off" -t BOLD old.tex new.tex > diff.tex
In both the markup in mathematical formulas is disabled. For the documentation, see CTAN.
Packages: fix-cm to scale fonts
A quick way of using nonstandard font sizes is to load the package fix-cm (the cm stands for Computer Modern). According to the documentation the orthodox form of loading this package is with \RequirePackage before specifying the class of the document:
\RequirePackage{fix-cm}
\documentclass[a4paper,11pt]{article}
The use is exemplified with
\fontsize{60pt}{70pt}\selectfont Very big tex
Here 60pt is the font size and 70pt is the baseline skip. Using brackets to give to the command a local scope does not respect the base line skip. The solution is to finish with \par like this:
{\fontsize{60pt}{70pt}\selectfont Very big tex\par}
Packages: fontenc to clean the file name
The command \jobname shows the name of the file. This can be problematic if it includes underscores. To avoid it, employ \usepackage[T1]{fontenc}.
Packages: geometry for the page layout
Including this package in the preamble followed by \geometry{...} with some parameters, we have a more intuitive control of the page layout. There is a list of the names of the arguments and their meaning in the Overleaf documentation An example taken from there is:
\usepackage{geometry}
\geometry{
  a4paper,
  total={170mm,257mm},
  left=20mm,
  top=20mm,
}
Here left is the real left margin, including 1 inch + \hoffset + \oddsidemargin and, analogusly, top is the rel top margin, form the upper border of the page to the body. The dimensions in total indicate the text area (the body).
Packages: graphicx to include an image
The main command in the package is \includegraphics[options]{filename}. We only discuss the main options through examples. The most usual purpose of the options is to adjust the size of the image. The three examples
\includegraphics[scale = 0.5]{./imag/figs.eps}
\includegraphics[height = 100pt]{./imag/figs.eps}
\includegraphics[height = 100pt, width = 50pt]{./imag/figs.eps}
are almost self-explanatory, assuming that we have the image file figs.eps in the folder ./imag. In the first example the image is reduced to one half of its original size. In the second example the height is adjusted to 100pt and the width change accordingly to keep the aspect ratio. The width is specified en the last examples and then the aspect ratio is distorted if different of 1/2.

A rotation can be specified assigning a value, in degrees, to angle. These are some examples:
\includegraphics[height = 100pt, angle = 20]{./imag/figs.eps}
\includegraphics[angle = 20, height = 100pt]{./imag/figs.eps}
\includegraphics[scale = 0.3, angle = 10]{./imag/figs.eps}
\includegraphics[scale = 0.3, origin = cc, angle = 10]{./imag/figs.eps}
\includegraphics[scale = 0.3, origin = br, angle = 10]{./imag/figs.eps}
The first and the second examples give, in general, a different result. If figs.eps has the same height and width, the first command generates a bigger figure because we adjust first the height 100pt while with the second command we rotate the figure first and it creates a bigger bounding box whose height is reduced to 100pt. In the last examples origin specifies the origin of the rotation. By default it is the "reference point" of the box. In a figure typically it is the left lower corner. We have some freedom to change it with two characters, one can be t (top), b (bottom) or c (center) and the other l (left), r (right) or c (center). For instance cc is the center of the figure, which can be abbreviated simply by c (in general a missing character is assumed to be c) and br is the right lower corner. In this way, in the three last examples the left lower corner is gradually descending.

It is possible to crop an image with the option trim, usually in combination with clip or, equivalently, clip = true. Here there is an example:
\includegraphics[scale = 0.5]{./imag/figs.eps}
\includegraphics[scale = 0.5, trim = {1cm 0.1cm 0.2cm 2cm}, clip]{./imag/figs.eps}
After showing the 1/2-scaled figure, we show the same figure trimmed (before scaling) 1cm on the left, 0.1cm on the bottom, 0.2cm on the right and 2cm on the top. If we omit clip then the bounding box is trimmed but the image is not. The result will be that both figures will overlap.
Packages: graphicx to manipulate boxes.
The package graphicx, beside \includegraphics, also defines the commands \rotatebox, \scalebox, \resizebox, for the manipulation of graphics or in general of boxes. The names are self-explanatory. The command \rotatebox has a first argument indicating the angle in degrees. A couple of examples are
\rotatebox{10}{This is a sentence}

\rotatebox{10}{\begin{minipage}{3cm}
This is a sentence in two lines.
\end{minipage}}
Note that in the first example, it is not necessary to create the box, the sentence has already one associated to it.
The first arguments of \scalebox is a dimensionless quantity indicating the horizontal scale. A second optional argument indicates the vertical scale. A couple of examples are
\scalebox{0.5}{word}
\scalebox{1}[2]{word}
In the first case the global size of word is reduced to 1/2. In the second case, the width is kept and the height is doubled. If the two arguments have different sign, it produces a mirror reflection. On the hand, there is also a \reflectbox that applies a vertical mirror reflection. Then \reflectbox{This is a sentence} and \scalebox{-1}[1]{This is a sentence} are equivalent.
Finally, \resizebox is a kind of variant of \scalebox in which the scales are substituted by absolute lengths. In this case, the two arguments are mandatory. If any of them is replaced by ! then the aspect ratio is preserved. For instance:
\resizebox{!}{!}{word}
\resizebox{30pt}{20pt}{word}
\resizebox{!}{20pt}{word}
The first example does not do anything, word appears as it is. With the second example the width becomes 30pt and the height 20pt. This height is preserved in the last example and the aspect ratio is the same as in word without any resizing. There is a variant of \resizebox named \resizebox*. The only difference is that the second argument specifies the "totalheight". With the terminology of boxes, this is the height plus the depth. The height is counted from the baseline and the depth measures the part below the baseline.
Important: Apparently the effect of \scalebox and \resizebox is only correctly shown in the PDF but not in the DVI file.
Packages: lineno for line numbering
With \usepackage{lineno} putting \linenumbers we get line number for that point onward or until \nolinenumbers. It can also used as an environment \begin{linenumbers}...\end{linenumbers}. By default, the line count is not reset when applied several times. The starting number can be specified as an optional argument of the environment. For instance:
\begin{linenumbers}
  Line one
  
  Line two
\end{linenumbers}

This line is not numbered

\begin{linenumbers}[7]
  Line seven
\end{linenumbers}

The numbering applies to text lines. To number also displayed formulas, use the argument mathlines of the package i.e., \usepackage[mathlines]{lineno}.
Packages: makeidx to make an index
With \usepackage{makeidx} and the command \makeindex in the preamble (before \begin{document}) and \printindex at the point in which we want to locate the index, we will have an alphabetical index with references to page numbers of every word or phrase marked with \index (e.g. \index{mathematics}, \index{number theory}).
Sometimes one wants to alter the alphabetical ordering mainly because the word contains symbols or accents. To solve this problem one can call \index as
\index{<item_for_ordering>@<item_for_showing>}
For instance \index{pi@$\pi$}, \index{easy@\textit{easy}}, \index{pinata@piñata}.
If in \index we separate several items with ! then they appear as subentries of the first item. It is possible to use several levels. For instance:
\index{Kloosterman sums!definition}
\index{Kloosterman sums!estimates!Weil}
\index{Kloosterman sums!estimates!Davenport}
Another use of \index is \index{<item>|see {<main_item>}} which refers to <main_item> preceded by the word see in italics.

For more information see the Wikibook of LaTeX.
Packages: overpic to overlap images and text
This packages must be loaded after graphicx and admits as parameters abs, percent and permil depending on if the positionin is in multiples of \unitlength, is a percentage or a per mille. The default is percent. For example, we can include in the preamble
\usepackage{graphicx}
\usepackage[percent]{overpic}
and [percent] is unnecessary.
The package offers the environment overpic which superimpose to an image other images or text with positions specified by \put. The optional arguments of the environment include grid to draw a grid (as help to position the objects) with separation given by tics and unit to specify the \unitlength. An example is
\begin{overpic}[grid, tics=15, unit=1mm]{./imag/figs.eps}
\put(35,50){\textbf{Repeating the}}
\put(45,42){\textbf{image}}
\put(0,0){\frame{\includegraphics[scale=.5]{./imag/figs.eps}}}
\put(0,0){\frame{\includegraphics[scale=.25]{./imag/figs.eps}}}
\put(0,0){\frame{\includegraphics[scale=.125]{./imag/figs.eps}}}
\end{overpic}
The result is the application three times of an homothety of ration 1/2 centered in the left lower corner. Loading the package as before, unit=1mm has no effect.
Packages: printlen to print lengths.
It adds the command \printlength{} which prints in the document the length acting as argument. For instance, with
The \verb!\textheight! is \printlength{\textheight} or
\uselengthunit{mm}\printlength{\textheight}
we get for an A4 document "The \textheight is 595.80026pt or 209.39738 mm".
Packages: scrextend to globally scale fonts
Putting in the preamble
\usepackage{lmodern}
\usepackage[fontsize=20pt]{scrextend}
the font size along the document will be 20pt. Loading lmodern it is not completely necessary but assures that we are using scalable fonts. It seems that there are issues with the math mode.
Packages: showkeys to show labels
With \usepackage{showkeys} we can see the labels in the output document when defined and when quoted. This can be a little disturbing. In general a better option is \usepackage[notcite,notref,color]{showkeys} which only shows the labels in formulas in a gray tone.
Packages: xcolor, background color
The command \colorbox{c}{text} makes a box containing text with background color c. For instance:
\colorbox{blue!10!white}{A pale blue background}
The box keeps a margin with respect the text. To omit it, one must set temporarly the length \fboxsep to zero with
{\fboxsep=0pt\colorbox{blue!10!white}{A pale blue background}}
When applied to a table, for instance
\colorbox{blue!10!white}{%
\begin{tabular}{cc}%
a&b \\ c&d%
\end{tabular}}
the background of all cells is colored. To select only some cells we have to load the package as \usepackage[table]{xcolor} and the command \cellcolor allows to select the color of a cell. For example
\begin{tabular}{ccc}
  \cellcolor{red!10!white}a&b&c \\
  d&\cellcolor{green!10!white}e&f \\
  g&h&\cellcolor{blue!10!white}i
\end{tabular}
colors the elements of the diagonal of the table with pale red, green and blue.
Packages: xcolor, color names
Loading the package with \usepackage[usenames,dvipsnames]{xcolor} we can use the names of the 68 colors known to dvips. They are listed here. For instance, one can write {\color{OliveGreen}Hi there!}. Note that the colors will appear correctly in the pdf but not necessarily in the dvi file.
Page: enlarge
Example: \enlargethispage{1cm} enlarges the height of the current page 1cm.
Page: layout variables
The length variables controlling the page layout are:
\hoffset -> Basic horizontal margin minus one inch.
\voffset -> Basic vertical margin minus one inch.
\oddsidemargin -> Increase in the \hoffset for odd pages.
\evensidemargin -> Increase in the \hoffset for even pages.
\topmargin -> The distance from the header to the lower part of the vertical margin. If negative (usual), the header may be contained inside the margin.
\headheight -> Height of the header.
\headsep -> Distance from the lower part of the header to the body.
\textheight -> The height of the body.
\textwidth -> The width of the body.
\marginparsep -> Separation between the horizontal margin and the space for margin notes.
\marginparwidth -> Width of the space for margin notes.
\marginparpush ->The minimum vertical space between two marginal notes.
\footskip -> Space between the lower part of the body and the lower part of the footer.
\paperheight -> The height of the paper. For A4 it is 845.04684pt (approx. 297mm).
\paperwidth -> The width of the paper. For A4 it is 597.50787pt (approx. 210mm).

The meaning is more clear in a figure. See it for instance in the Overleaf documentation or in the p.115 of The Not So Short Introduction to LaTeX2ε.
Page: multiple page titles
The environment titlepage allows to add several title pages. This can be used to make what it is called in the jargon of book design a "half title". This title page appears without page number and without heading. The page numbering will start by 1 after it.
Page: no page numbers
In some formats or headings it is difficult to suppress completely the page numbers. An extreme solution is \renewcommand{\thepage}{}.
Page: references
The command \pageref{<label>} shows the page number in which a certain label appears.
Paragraphs: indentation
By default every paragraph has an indentation stored in the variable \parindent. In this way, we disable the indentation with \setlength{\parindent}{0pt}.
The commands to force indentation or the lack of it, are \indent and \noindent. When a section starts the indentation is disabled and the command \indent does not work in this situation. An alternative is \makebox[0pt]{}\indent.
In user defined environments it may appear an unexpected indentation at the beginning or extra spaces at the end. To avoid it, it is convenient to start the definition with \noindent\ignorespaces and finish it with \noindent\ignorespacesafterend.
Paragraphs: margin notes
The command \marginpar adds a margin note. In the oneside format, it appears to the right. In the twoside format it appears in the exterior part (right for odd, left for even). To change this default behavior in any of the formats the command \reversemarginpar have to precede the margin note. To come back the the default behavior, use \normalmarginpar. Example:
First paragraph.\marginpar{Note 1}

Second paragraph.\reversemarginpar\marginpar{Note 2}

Third paragraph.\normalmarginpar\marginpar{Note 3}
Although it is possible to add several notes in the same paragraph it may raise a warning Margin par ... moved. The commands \normalmarginpar and \reversemarginpar affect to all notes in the paragraph.
Spanish: decimal point
In principle in Spanish the rule is to use decimal commas instead of decimal points then $1.3$ shows (with [spanish]{babel}) 1,3. It causes some problems, for instance in the coordinates of a vector. To change this default behavior and use decimal points as in English it is enough to write in the premable the command \decimalpoint after loading the babel package.
Summation: multiple sums with limits
The command \mathop allows to group several sums to admit common limits like this:
\mathop{\sum\ \sum}_{\substack{1<x+y<100\\ 2<3x-y<40}}
The spacing between sums may need some adjustment.
Summation: prime
Use \sideset{}{'}\sum to put a prime in a sum in the right place. It also works if the sum has limits. If the first argument of \sideset is not empty, its content appears preceding the sum. It does not seem very useful.
Table of contents: add or remove items
It is well known that with !\chapter*{...}*!, !\section*{...}*!, etc. we remove these items from the table of contents. To add an item the command is \addcontentsline{toc}{<unit>}{<text>} where <unit> means chapter, section, etc. The following paradoxical example combines add and removing an item. The effect is that we get "Prologue" in the table of contents but it is not included as a numbered section.
\section*{Prologue}
\addcontentsline{toc}{section}{Prologue}
A more orthodox version of the example is:
\section*{Prologue}
\addcontentsline{toc}{section}{\protect\numberline{}Prologue}
It keeps the alignment with the rest of the item with the same rank.
Table of contents: depth
The counter tocdepth indicates the depth of table of contents. For instance
\setcounter{tocdepth}{0}
\tableofcontents
would show only the chapters with the book class and the table of contents would be empty with the article class. Changing {0} by {1}, {2} or {3} we see also sections, subsections or subsections.
Table of contents: title
The variable \contentsname stores the title of the table of contents. It can be changed like in this example
\renewcommand{\contentsname}{This is the table of contents}
\tableofcontents
Templates: letter class
To write a letter.
\documentclass[11pt,a4paper]{letter}
\signature{The author}
\address{The sender \\ Street \\ Zip code \\ Country}
\begin{document}
\begin{letter}{The recipient \\ Street \\ Zip code \\ Country}
\date{October 20, 1984}
\opening{Dear Editor,}
The text of the letter
\closing{Best regards,}
\ps{P.S. I forgot to say\dots}
\end{letter}
\end{document}
Types: footnotesize bug
By some reasons sometimes when footnotesize is applied to several paragraphs as an environment the final lineskip is altered. To avoid this awkward behavior it is enough to close the environment with
{}
\end{footnotesize}
Types: italic boldface
A simple trick to obtain italic boldface types is \textbf{\itshape Italic boldface}.
Types: mathematical boldface
It is well known that \mathbf{...} allows to use boldface letters in the mathematical mode but this command does not affect to Greek letters and mathematical operators. A "poor man" solution is the command \pmb{}. The name abbreviates "poor man boldface" and it superimposes the argument with a slightly translated version of it. Try for instance $\pmb{\alpha=\beta}=\pmb{\gamma}$. For a more professional solution use \mathversion{bold} which will turn every formula into boldface until deactivated with \mathversion{normal}. For instance, with
\mathversion{bold}
$\alpha=\beta$
\mathversion{normal}
$\alpha=\beta$
the first formula appears in boldface and the second does not. The drawback of \mathversion is that it only applies to entire formulas.




nom3