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
__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$.
- 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
- The set of integers $\Z = \{\dotsc,-2,-1,0,1,2,\dotsc\}$ (source [2]).
- The set of non-negative integers is $\Z_{\ge 0} = \{0,1,2,\dotsc\}$ (or $\Z_+$) (source [2])
- The set of strictly positive integers is $\Z_{> 0} = \{1,2,\dotsc\}$ (or $\Z_+^*$) (source [2])
- A finite set of integers is denoted $\{1,2,\dotsc,n\}$ (source [3])
- Alternatively one can use $\N_{n}^*$ or $\Z \left({n}\right)$ (source [2])
- The set of integers modulo n is $\Z_n=\{0,1,2,\dotsc,n-1\}$ (source [3])
- The multiplicative group of $\Z_n$ is $\Z_n^* = \{a \in \Z_n | \gcd(a,n) = 1\}$ (source [3])
- Also known as the set of coprime integers to $n$, denoted as $\Z'_n = \{ k \in \Z_n : a \perp n\}$ (source [2])
- The set of integer multiples $n \Z$ (source [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 set:
A \cong B
$A \cong B$, orA \simeq B
$A \simeq B$.
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