Questions tagged [best-practices]

A "best practice" is a technique or approach that TeXnicians recognize as giving better results than other approaches.

Filter by
Sorted by
Tagged with
469 votes
3 answers
1.1m views

"Correct" way to bold/italicize text?

Is either of these considered better/more readable/more "proper"/more conventional than the other for making text bold? If so, what is the reason? I like my text \textbf{bold} versus: I like my ...
user avatar
  • 8,637
356 votes
10 answers
75k views

Are \( and \) preferable to dollar signs for math mode?

Along the lines of Why is \[ ... \] preferable to $$ ... $$?, what reasons are there (if any) to favor \( ... \) over $ ... $?
user avatar
  • 16.1k
236 votes
2 answers
168k views

When to use \par and when \\, \newline, or blank lines

What is the difference between \par, \newline, \\ and blank lines? When should I use which one?
user avatar
  • 8,029
224 votes
2 answers
103k views

Should \tikzset or \tikzstyle be used to define TikZ styles?

The PGF/TikZ manual states in section 12.4 Using Graphic Options, page 120 (v2.10), that TikZ styles can be set using: \tikzset{my style/.style={<tikz options>},...} However, in several places ...
user avatar
223 votes
6 answers
873k views

Which dot character to use in which context?

Wikipedia lists several dot characters in Unicode. These are the ones that are ambiguous to me: interpunct, middle dot (·) &middot; &#183; U+00B7 "midpoint (in typography)" ...
user avatar
  • 2,331
220 votes
6 answers
221k views

utf8x vs. utf8 (inputenc)

I normally use \usepackage[utf8]{inputenc} for my latex document but on this site i saw a lot of code with \usepackage[utf8x]{inputenc}. What are the differences between the 2 options ? Is there one ...
user avatar
  • 7,285
215 votes
2 answers
393k views

How to write conditional equations with one-sided curly brackets [duplicate]

I want to write a conditional expression such as the following. What is the best way to express such conditional expressions in Latex?
user avatar
203 votes
2 answers
169k views

\emph or \textit

In the comments section of Does it matter if I use \textit or \it, \bfseries or \bf, etc, I asked for a clarification of these points. The clarification has mostly been made, but it was requested that ...
user avatar
  • 3,819
192 votes
46 answers
22k views

What are the most common mistakes that beginners of (La)TeX and Friends make?

I want to collect the most common mistakes, misconceptions, pitfalls, etc that (La)TeX and Friends users make. Please one answer for each mistake, misconception, pitfall, etc. I am only interested in ...
160 votes
3 answers
47k views

Which measurement units should one use in LaTeX?

There are various measurement units that one can use (such as pt, mm, in, em, ex etc.) for specifying lengths and heights. For font-based units (em and ex) the actual spacing will vary slightly ...
user avatar
  • 2,389
148 votes
5 answers
14k views

Best practice on organising your preamble

I am putting together a large document and my preamble is unwieldly and disorganised. What order does it make sense to load packages. Obviously, hyperref goes last, apart from things that have to go ...
user avatar
  • 69.9k
139 votes
3 answers
50k views

What is the difference of \mathop, \operatorname and \DeclareMathOperator?

One sees all kind of versions in source files for defining something like a limit etc. So my question is which one serves what purpose. Is there any "best practice" in chosing one over the other?
user avatar
136 votes
6 answers
140k views

What is the advantage of using $f^\prime$ instead of $f'$?

Although the two outputs look quite similar, what is the advantage of using $f^\prime$ instead of $f'$? By the way, here is my code: \documentclass‎{article‎}‎ \begin{document}‎‎‎ \[‎ ‎f^‎\prime ‎(x)=...
user avatar
136 votes
5 answers
42k views

Is there a preference of when to use \text and \mathrm?

I'm unsure of when it is preferable to use \text versus \mathrm, is there some unwritten rule about the use of these? For example, I saw the following code in a math post: \frac{\mathrm{lcm}(m,n)}{\...
user avatar
  • 3,149
135 votes
2 answers
48k views

When should one use \begingroup instead of \bgroup?

Is there ever a case when the use of \begingroup is preferred to \bgroup? Obviously, \bgroup is necessary in cases where you need to have balanced braces and thus cannot use {, but when is it ...
user avatar
  • 59.7k
131 votes
4 answers
241k views

"(" or "\left(" parentheses?

What is the difference between ( and \left( in LaTeX? Sometimes, when the content is small, it does not seem to matter which pair I use. What is the best practice when it comes to which parentheses ...
user avatar
  • 9,761
131 votes
4 answers
57k views

When not to use \ensuremath for math macro?

I have gotten into the habit of using \ensuremath around math components in every macro that I define, so that I can use the same macro inside and outside of math mode. But egreg's comments in \...
user avatar
129 votes
6 answers
95k views

Should I \mathrm the d in my integrals?

When writing an integral, it seems like something should be done to separate the "d", as in \int f(x) dx, so as not to confuse it with a variable. I've seen it left as-is, bolded, and straightened. ...
user avatar
  • 1,393
121 votes
5 answers
6k views

What are the finishing touches you put to a document?

I'm curious about the finishing touches that people put to LaTeX documents. Are there any canonical or special things that people do in finalizing a document? What I do: Careful proofreading of the ...
120 votes
3 answers
23k views

Are there any coding style guidelines for LaTeX?

I have been using LaTeX for a long time now, but still all my document files look a bit messy. Now I want to get rid of this bad habit and get some order into my code. That is why I am wondering ...
user avatar
  • 19k
117 votes
5 answers
48k views

Does it matter if I use \textit or \it, \bfseries or \bf, etc

I typically use \textit{Some italicized text} while some of my colleagues use {\it Some other text} Should I bother changing one or the other, or does it matter? Related: Is there any reason ...
user avatar
  • 3,218
114 votes
6 answers
55k views

When should I use non-breaking space?

DEK gained a reputation of painting red the draft dissertations of his students, taking particular note of incidents when they omitted a non-breaking space that should have been included. I have this ...
user avatar
  • 15.1k
111 votes
6 answers
9k views

How to keep up with packages and know which ones are obsolete?

I'm an on and off user of LaTeX so I'm not familiar with every package out there. Having said that, whenever I use LaTeX and need to accomplish a certain goal (i.e. generate a list of appendices), I ...
user avatar
  • 1,315
103 votes
2 answers
13k views

Why should the minimal class be avoided?

In a comment to my answer to Drawing a rectangle along the border of a circle, Peter Grill said that he read that the minimal class should not be used for a Minimal Working Example. I wonder why, and ...
user avatar
  • 53.3k
101 votes
4 answers
6k views

Techniques and packages to keep up with good practices

Question What techniques and packages are there to keep up with good practices? What I already know I already know of the following packages for this kind of purpose: \RequirePackage[l2tabu,...
user avatar
  • 34.4k
100 votes
3 answers
18k views

Theorem packages: which to use, which conflict?

As far as I know, one can create theorem environments using any of amsthm, ntheorem, thmtools and probably more. How should I define my theorem environments? Is one package clearly superior? Which ...
user avatar
  • 69.9k
97 votes
4 answers
8k views

Detecting unused packages in LaTeX document

I have quite a bad habit of copy-and-pasting my packages from one LaTeX document to another. Is there any way we can detect unused packages (i.e. \usepackage commands) so that they can be removed from ...
user avatar
  • 1,195
96 votes
4 answers
21k views

What is the proper use of \@ (i.e., backslash-at)?

In this answer, \@ is used after a period and before an \xspace, presumably to indicate that the preceding period (in "etc.") was not sentence-final. In these tips, \@ is used before a period and ...
user avatar
  • 6,762
94 votes
3 answers
35k views

Best practice for hyperref link colours?

I'm using the hyperref package with the option colorlinks=true. However, I'm not happy with the default link colours: for instance, citation links appear in a flamboyantly bright green that hurts my ...
user avatar
  • 56.4k
89 votes
13 answers
28k views

What are the advantages of using version control (git, etc.) in LaTeX documents

Why would I need to use version control with my LaTeX documents? I know people who do it, and I've seen questions about it on here and on SO, but I haven't understood what value there is to doing it......
user avatar
  • 69.9k
87 votes
1 answer
9k views

On the basics of writing to & reading from auxiliary files (.aux, .toc, etc.)

Some actions (such as generating the Table of Contents) require two passes of the TeX compiler: during the first pass, some data get written to an auxiliary file, only to be retrieved during the ...
user avatar
  • 56.4k
85 votes
1 answer
19k views

When to use the xcolor package instead of the color package?

Can someone explain when to use the xcolor package instead of the color package? Unless you are creating your own specific colors, the differences between the packages seem to be fairly superficial. ...
user avatar
  • 9,492
84 votes
5 answers
57k views

Why use a package to typeset units?

I've seen a lot of posts about different packages for typesetting units and their relative strengths and weaknesses. Most posts seem to agree that the siunitx package is the most up to date package, ...
user avatar
  • 1,335
84 votes
5 answers
31k views

Good practice on spacing

In various places, in passing, I've seen mention of various good practices regarding well-behaved spacing in LaTeX. For example, Dr. Who should really be written Dr.\ Who or Dr.~Who to get the right ...
83 votes
12 answers
10k views

Best practices references

What resources (online or otherwise) exist that give good advice on best practices for TeX, etc.? I'm looking particularly for things that assume you already know TeX or LaTeX, and aim to help you ...
83 votes
1 answer
60k views

Is there any advantage to using \addbibresource over \bibliography?

I've always used \bibliography to tell BibTeX where my bibliography is, and when I moved to biblatex, I didn't change. I see a lot of biblatex answers use \addbibresource instead. What is the ...
user avatar
  • 69.9k
82 votes
5 answers
8k views

What is best way to mention that a document has been typeset with TeX?

Is there any common way to mention that a document has been typeset by TeX? So non-TeXnicians (TeXperts) may become a little familiar with the TeX world. Update: It would be nice if one hero make a ...
user avatar
80 votes
3 answers
77k views

Why use .sty files?

Why is it preferable to put inclusions of commonly used packages and user defined commands in a .sty file instead of putting them in an ordinary .tex file?
user avatar
  • 3,467
78 votes
9 answers
73k views

Footnotes in tables?

I would like to have footnotes in tables, but the \footnote command does not work inside a table environment. Googling one finds that this is a frequently asked question, at least in the UK. That ...
user avatar
78 votes
1 answer
19k views

Difference between ref, varioref and cleveref. Decision for a thesis

How can one make a quick decision what the best "ref" for a thesis in pdflatex with hyperref is? After a few hours reading I do not know more than ref is used by everyone who does not know about the ...
user avatar
  • 8,029
77 votes
6 answers
3k views

How bad for TeX is omitting braces {}, even if the result is the same?

Sometimes writing braces and omitting them produces the same result: \tilde{\psi} \mathrm{e}^{\mathrm{i} \pi} vs \tilde \psi \mathrm e^{\mathrm i \pi} Or (taken from Werner's comment below) \...
user avatar
  • 4,498
74 votes
6 answers
30k views

Which figure type to use: pdf or eps?

Both are vector graphics (typically) and both can be imported painlessly into a pdflatex document (so let's say we ignore dvi for this question). What are the advantages and disadvantages of each? ...
user avatar
  • 12.3k
71 votes
3 answers
2k views

Advantages and disadvantages of fully expandable macros

As I currently understand them, fully-expandable macros are analogous to pure/effect-free functions in functional programming. Correspondingly, things that are not expandable, such as \def, are ...
user avatar
71 votes
2 answers
1k views

Is it always best practice to not include text punctuation in inline math mode?

It has been pointed out on this site, e.g. here by egreg, that text punctuation doesn't belong to the formula in inline math. I've been following this practice for a long time, so I write for all $v\...
user avatar
  • 36.5k
69 votes
2 answers
71k views

typesetting modulus operator, as in remainder

Is there a standard way to typeset the modulus operator (as in arithmetic remainder)? The percent sign (%) is often used by programming languages and mathematicians tend to use mod, but because of the ...
user avatar
  • 7,564
66 votes
7 answers
18k views

Efficient ways to anonymize a document

Many academic journals practice double-blind peer review which means that the author is required to blind their document by removing any references that can reveal the author's identity. How can I ...
user avatar
  • 34.4k
65 votes
8 answers
6k views

Why should you avoid using (complex) templates?

This question is intended to be something reference-like to point users of complex templates they do not fully understand to. After having read What is a template? it should be clear what a template ...
user avatar
  • 32.1k
65 votes
3 answers
22k views

What is the difference between unicode-math and mathspec?

I'm currently typesetting my lecture notes for classical electrodynamics using the tufte-book class and XeLaTeX. This is my first time using XeLaTeX and so I stumbled upon the two packages unicode-...
user avatar
64 votes
4 answers
6k views

Defining custom commands is bad style?

I recently received this in a e-mail from my professor Good LaTeX style would preclude creating any of your own commands, counters, etc. (Most journals would reject submissions with user-defined ...
user avatar
  • 2,151
64 votes
2 answers
11k views

Styleguide for LaTeX similar to the Google styleguides?

Even though I don't work at Google, the Google Styleguides have been very helpful for me in adopting consistent, readable style conventions for my code. Unfortunately, there is no Google Styleguide ...
user avatar
  • 5,123

1
2 3 4 5
15