LaTeX writing tips: Difference between revisions
Jump to navigation
Jump to search
Line 51: | Line 51: | ||
* $\lg x$ is the logarithm of $x$ to the base $2$. |
* $\lg x$ is the logarithm of $x$ to the base $2$. |
||
* Convention about ''positive'', ''greater than''... |
* Convention about ''positive'', ''greater than''... |
||
⚫ | |||
** ''Positive'' integers are integers ''greater than'' 0, i.e. $x>0$. |
** ''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$. |
** ''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$. |
** ''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$. |
** ''Non-negative'' integers are integers ''greater than or equal to'' 0, i.e. $x\ge 0$. |
||
⚫ | |||
;Bitsize |
;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 |
* 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 |
||
Line 65: | Line 64: | ||
|- |
|- |
||
|$\mathbf N$ |
|$\mathbf N$ |
||
|<code>$\ |
|<code>$\mathbb N$</code> |
||
|The set of ''natural numbers'', including 0, i.e. $\N = \{0,1,2,\dotsc\}$ |
|The set of ''natural numbers'', including 0, i.e. $\N = \{0,1,2,\dotsc\}$ |
||
|} |
|} |
Revision as of 11:37, 27 October 2014
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 one must say strictement supérieur to exclude 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
$\mathbf N$ | $\mathbb N$
|
The set of natural numbers, including 0, i.e. $\N = \{0,1,2,\dotsc\}$ |
- Integer sets are usually denoted with the blackboard fonts $\mathbb N$, $\mathbb Z$, $\mathbb Q$, $\mathbb R$, or with bold sans-serif face $\mathbf{\mathsf{N,Z,Q,R}}$ (although
$\textsf{$\textbf N$}$
gives better results).- Some authors argue that bold face is the original convention, and blackboard typeface was used for black board only.
- 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 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}$$
- Inline function definition: $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