LaTeX writing tips
Jump to navigation
Jump to search
Layout and Typesetting
See also: English writing tips
- Maintain the relation 1 paragraph = 1 thought across the document.
- English requires longer space after the dots terminating a sentence (see
\@
); French does not (see\frenchspacing
}. - Add footnote after the word or sentence they refer to (i.e. after the comma or periodrelated to a sentence after the terminating dot.
- Avoid ligatures crossing morpheme boundary in a composite word, like shelfful ([1])
- Use ` and ' or `` and as quotation marks in English (or << and >> in French)
- Use the correct dash for each use (X-rated, page 13--67, yes---or no?, $-1$)
- Use
\dots{}
instead of\dots
to add a space after the dots:
This is the end\dots Bye! # Bad This is the end\dots{} Bye! # Good
- Use the correct semantic
\dotsx
command, depending on context:
We have the series $A_1,A_2,\dotsc$, % for comma list
the sum $A_1+A_2+\dotsb$, % for binary op
the orthogonal product $A_1A_2\dotsm$, % for multiplication dots
the infinite integral $$\int_{A_1}\int_{A_2}\dotsi$$. % for dots with integrals
- Use roman style for 'd' in the differential:
\newcommand{\ud}{\,\mathrm{d}}
\begin{equation*}
\int_a^b f(x)\ud x
\end{equation*}
- Use
\textsubscript{}
or\textsuperscript{}
for subscripts our superscripts outside math (like CO2 or 4th). The preferred option for ordinals in mathematics texts (or even english) seems to use$n$th
or$n$-th
(like nth or n-th) [2], [3], [4]. Yet another option is$n^{\text{th}}$
(with amsmath package). Finally, there is the package nth that can render ordinal with\nth{4}
but it only works with numbers.
The $4$th, or the $4$-th, or the $4^{\text{th}}$ or the $4^{\text{\tiny{th}}}$ or the $4$\textsuperscript{th} or \nth{4}?
- Cut long line by adding a
%
at the cut to avoid LaTeX adding unwanted space where the cut occurs:
\State $u \gets (v_i - x)\cdot C_i \bmod \rsamod_i$, $x \gets x + u \cdot% This comment will prevent LaTex adding space
\prod_{j=1}^{i-1}\rsamod_j$
- When using cleveref, use
\Cref{}
instead of\cref{}
at the beginning of a sentence to enforce capitalization. - Interword spaces [5] — “TeX assumes a period ends a sentence unless it follows an uppercase letter.” (Lamport p. 14). So, put a
\
in a sentence likeSmith et al.\ say that ...
. And, if an uppercase letter ends a sentence, do a\@
before the period:In the class, I gave Bob a C\@.
. - The small package xspace (by David Carlisle) defines the
\xspace
command, for use at the end of macros that produce text. It adds a space unless the macro is followed by certain punctuation characters.[1].
\newcommand\eg{e.g.\@\xspace}
\newcommand\ie{i.e.\@\xspace}
\newcommand\etc{etc.\xspace}
- Units [6] — Use a non-breaking space between quantity and unit:
10~m
. Or use package siunitx package (\SI{10}{m}
) - Use unbreakable space in compound names (like
Van~Allen
)
Conventions and Examples
See also latex_templates examples. __MATHJAX_DOLLAR__
- Usual conventions
- $\ln x$ is the natural logarithm of $x$; that is, the logarithm of $x$ to the base $e$.
- $\lg x$ is the logarithm of $x$ to the base $2$.
- Convention about positive, greater than...
- Positive integers are integers greater than 0, i.e. $x>0$.
- Non-positive integers are integers less than or equal to 0, i.e. $x\le 0$.
- Negative integers are integers less than 0, i.e. $x<0$.
- Non-negative integers are integers greater than or equal to 0, i.e. $x\ge 0$.
- These are the English conventions. The French conventions are different: positif means $x\ge 0$, and supérieur means supérieur ou égal, and strictement supérieur excludes equality.
- Bitsize
- A $n$-bit integer $N$ ... we know the high order $(1/4+c)(log_2 N)$ bits of P ... $\lceil log_2 N \rceil$-bit integer
- Integers
$\mathbb{N\ Z\ Q\ R}$ $\textsf{$\textbf{N Z Q R}$}$ |
$\mathbb N$
|
Sets in algebra are usually denoted with blackboard typeface. Bold sans-serif is also a possible, but a bit less convenient in $\LaTeX$. | |
$\mathbb N$ | $\mathbb N$
|
The set of natural numbers, including 0, $\{0,1,2,\dotsc\}$. Other notations include $\N^0\ \N_0$. |
|
$\mathbb N^*$ | $\mathbb N^*$
|
The set of positive natural numbers, $\{1,2,\dotsc\}$. Other notations include $\N^+\ \N_1\ \N_{>0}$. |
|
$\mathbb Z$ | $\mathbb Z$
|
The set of integers, $\{\dotsc,-2,-1,0,1,2,\dotsc\}$ | [2] |
$\mathbb Z_{\ge 0}$
(or $\mathbb Z_+$) |
$\mathbb Z_{\ge 0}$
(or |
The set of non-negative integers, $\{0,1,2,\dotsc\}$ | [2] |
$\mathbb Z_{> 0}$
(or $\mathbb Z^*_+$) |
$\mathbb Z_{> 0}$
(or |
The set of strictly positive integers, i.e. $\{1,2,\dotsc\}$ | [2] |
$\{1,2,\dotsc,n\}$ (or $\N_{n}^*$ or $\Z \left({n}\right)$) |
$\{1,2,\dotsc,n\}$
|
A finite set of integers. | [3][2] |
$\Z_n$ | $\Z_n$
|
The set of integers modulo n, $\{0,1,2,\dotsc,n-1\}$ | [3] |
$\Z_n^*$ | $\Z_n^*$
|
\gcd(a,n) = 1\}$ This is also known as the set of coprime integers to $n$, denoted as $\Z'_n = \{ k \in \Z_n : a \perp n\}$ |
[3][2] |
$n \mathbb Z$ | $n \mathbb Z$
|
The set of integer multiples $n \mathbb Z$ | [2] |
- Tuples
- a 2-tuple is an ordered pair (aka. couple in french, not be confused with pair where element order does not matter) (source [4]).
- a 3-tuple is a triplet (source [4]).
- Graphs (tree...)
- Height of a node = distance to root node; height of the tree = maximum height.
- degree of a node = number of children of a node; node with degree 0 = leaf node; node with no parent = root node.
- Matrices
- Vector or matrix transpose: Use
^\top
$\mathbf M^\top$ (alt.^\mathsf{T}
$\mathbf M^\mathsf{T}$, or^\intercal
$\mathbf M^\intercal$) [7] - Vector or matrix conjugate: Use
^*
$\mathbf A^*$
- Sets
- Isomorphism between 2 sets:
A \cong B
$A \cong B$, orA \simeq B
$A \simeq B$.
- Functions
- Example of function definitions:
$$\begin{array}{llll}
f : & \Z_N \to \Z_N & \qquad f^{-1}: & \Z_N \to \Z_N\\
& x \mapsto x^e \bmod N & & x \mapsto x^d \bmod N
\end{array}$$
|
$$\begin{array}{llll} f : & \Z_N \to \Z_N & \qquad f^{-1}: & \Z_N \to \Z_N\\ & x \mapsto x^e \bmod N & & x \mapsto x^d \bmod N \end{array}$$ |
- Inline function definition:
$f : \{0,1\}^* \to \ZZ_{N}$, $x\mapsto b^x\bmod N$
|
$f$ is defined as $f : \{0,1\}^* \to \ZZ_{N}$, $x\mapsto b^x\bmod N$ |
References
- ↑ Frank Mittelbach,Michel Goossens: The LaTEX Companion — Second Edition. Addison-Wesley, 2004
- ↑ 2.0 2.1 2.2 2.3 2.4 2.5 ProofWiki, Symbols:Z — ProofWiki, http://www.proofwiki.org/wiki/Symbols:Z, 2013
- ↑ 3.0 3.1 3.2 Menezes, A., van Oorschot, P., Vanstone, S.: Handbook of Applied Cryptography, 1997
- ↑ 4.0 4.1 Wikipedia, https://en.wikipedia.org/wiki/Tuple