LaTeX tricks that save time in typesetting In ${\rm\LaTeX}$ typesetting, when we repeat a long and complex formula in long documents, it is appropriate to create a new command that just by calling this new command we get the desired output. For example, I have used the following math expression in my previous document frequently:
$$\{a^1,a^2,\ldots,a^n\}$$
For doing this in usual way, we need to press 22 keys on keyboard (and think about $(\frac{\partial}{\partial x^1}, \cdots,\frac{\partial}{\partial x^n})$ and other terrible formulas). Of course we can do this by copy and paste from similar one in the text. it is much better to define the following new command on preamble
\newcommand{\set}[1]{\setaux#1\relax}
\def\setaux#1#2#3\relax{%
  \{ {#1}#2 1,
  \ifnum\pdfstrcmp{#3}{3}=0
    {#1}#2 2
  \else
    \ldots
  \fi
  , {#1}#2{#3} \}
}

and just by typing \set{a^n} in our text we get the same output.

Question: What are your favorite ${\rm\LaTeX}$ tricks that save your time in long document typesetting?

 A: I found Python's option to generate \LaTeX output from symbolic calculations quite useful. One specific usecase was to calculate higher derivatives of rotated explicit functions, which I calculated with SymPy:
import sympy
from sympy.printing import latex as spl

sympy.init_printing()
t = sympy.Symbol("t")
r = sympy.Symbol("r")
f = sympy.Function("f")(t)        # the explicit function f(t)
x = sympy.cos(r)*t-sympy.sin(r)*f # x-coordinate after rotation 
y = sympy.sin(r)*t+sympy.cos(r)*f # y-coordinate after rotation
# 1st derivative w.r.t. x after rotation
dy = sympy.Derivative(y,t)
dx = sympy.Derivative(x,t)
d1 = dy.doit()/dx.doit()
#  2nd derivative w.r.t. x after rotation
d2 = sympy.Derivative(d1,t)
d2 = d2.doit()/dx.doit()
d2 = sympy.trigsimp(d2)
#  3rd derivative w.r.t. x after rotation
d3 = sympy.Derivative(d2,t)
d3 = d3.doit()/dx.doit()
d3 = sympy.trigsimp(d3)
#  4th derivative w.r.t. x after rotation
d4 = sympy.Derivative(d3,t)
d4 = d4.doit()/dx.doit()
d4 = sympy.trigsimp(d4)
d4 = d4.collect(sympy.cos(r)).collect(sympy.sin(r)).collect(sympy.cos(2*r)).collect(sympy.sin(2*r))   


## generate \LaTex code in e.g. IPython console:
In [1]: spl(d1)
Out[1]: '\\frac{\\sin{\\left (r \\right )} + \\cos{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )}}{- \\sin{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )} + \\cos{\\left (r \\right )}}'
In [2]: spl(d2)
Out[2]: '- \\frac{\\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )}}{\\left(\\sin{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )} - \\cos{\\left (r \\right )}\\right)^{3}}'
In [3]: spl(d3)
Out[3]: '\\frac{1}{\\left(\\sin{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )} - \\cos{\\left (r \\right )}\\right)^{5}} \\left(\\sin{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )} \\frac{d^{3}}{d t^{3}}  f{\\left (t \\right )} - 3 \\sin{\\left (r \\right )} \\left(\\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )}\\right)^{2} - \\cos{\\left (r \\right )} \\frac{d^{3}}{d t^{3}}  f{\\left (t \\right )}\\right)'
In [4]: spl(d4)
Out[4]: '\\frac{1}{\\left(\\sin{\\left (r \\right )} \\frac{d}{d t} f{\\left (t \\right )} - \\cos{\\left (r \\right )}\\right)^{7}} \\left(\\left(\\frac{d}{d t} f{\\left (t \\right )} \\frac{d^{4}}{d t^{4}}  f{\\left (t \\right )} - 5 \\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )} \\frac{d^{3}}{d t^{3}}  f{\\left (t \\right )}\\right) \\sin{\\left (2 r \\right )} + \\left(\\frac{1}{2} \\left(\\frac{d}{d t} f{\\left (t \\right )}\\right)^{2} \\frac{d^{4}}{d t^{4}}  f{\\left (t \\right )} - 5 \\frac{d}{d t} f{\\left (t \\right )} \\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )} \\frac{d^{3}}{d t^{3}}  f{\\left (t \\right )} + \\frac{15}{2} \\left(\\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )}\\right)^{3} - \\frac{1}{2} \\frac{d^{4}}{d t^{4}}  f{\\left (t \\right )}\\right) \\cos{\\left (2 r \\right )} - \\frac{1}{2} \\left(\\frac{d}{d t} f{\\left (t \\right )}\\right)^{2} \\frac{d^{4}}{d t^{4}}  f{\\left (t \\right )} + 5 \\frac{d}{d t} f{\\left (t \\right )} \\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )} \\frac{d^{3}}{d t^{3}}  f{\\left (t \\right )} - \\frac{15}{2} \\left(\\frac{d^{2}}{d t^{2}}  f{\\left (t \\right )}\\right)^{3} - \\frac{1}{2} \\frac{d^{4}}{d t^{4}}  f{\\left (t \\right )}\\right)'  

so, what remains to be done is to replace double backslashes by single ones and to provide the \$ signs
A: Commands like \pd{f}{x} (= $\frac{\partial f}{\partial x}$) defined by \newcommand\pd[2]{\frac{\partial #1}{\partial #2}} is very useful. It would be better if there is a generalized command of this like \pd{f}{x}{y}{z}... for $\frac{\partial^k f}{\partial x\partial y\partial z...}$ and add it to amspackage.
Edit (after comment of @pbelmans): Such commands are avalible in diffcoeff package.
A: In case you want to use tikzcd to draw diagrams this tikzcd editor saves lot of time.
\begin{tikzcd}  &  & A \arrow[rr] \arrow[lld] \arrow[dd] &  & V \arrow[d] &  \arrow[dd] \\ 
 & V \arrow[dd] \arrow[ru] \arrow[ldd] &  \arrow[rru] &  \arrow[d] & V &  \\
  &  & V \arrow[rru] &  &  \arrow[ru] \arrow[lu] \arrow[l] &  \\ 
 & V \arrow[ru] \arrow[rr] &  &  &  &  \end{tikzcd}

In some sense, I have written above code in less than 1 minute.
It is self-explanatory how to draw diagrams.
In bottom of the page, you have an option to copy the code.
A: A really useful website is GroupNames created by Tim Dokchitser https://people.maths.bris.ac.uk/~matyd/GroupNames/
It lists all finite groups of order $n$ with $n \leq 500$, with the exception of $n=256,384$, and has great search features. When you click on a group, you are given all sorts of useful information about that group (this is often way quicker than using a computational algebra system such as Magma or Sage). In particular, there is the option to export the latex code for the subgroup lattice and the character table. The latter saved me a ton of time when teaching a course on representation theory of finite groups!
A: Detexify http://detexify.kirelabs.org/classify.html
allows your to draw the symbol you want and then it will output a list of the most probable latex commands for that symbol.
A: To give another answer:
The package cleveref should almost be mandatory.
Referring to a label, one can use \cref{thelabel} to produce things like Lemma 2, Theorem 5, etc where "Lemma" and "Theorem" are deduced automatically from the object with the label.
Thus, changing a proposition to a theorem, or a section to a subsection, is pain-free, as all instances of Proposition 5 becomes Theorem 5. This saves a lot of time.
A: For $\LaTeX$ typing, i create an online tool (link : https://latexeditor.lagrida.com/) with code examples, and every time i need a code i juste click on examples :


I can also write formulas very easly by few clicks:

A: I like the package cells by Sergei Ivanov, which allows to write 

to produce 

A: I'm not sure but new commands can be inconvenient for the editors. So the long plain commands can be better in this case. In order to save time I use macros which replace some simple strings by usual $\LaTeX$ commands and put cursor at appropriate position. Simple examples are
\begin{align*}
...&\to\verb"\ldots"\\
\verb"//"&\to\verb"\frac{}{}"\\
\verb"`a"&\to\verb"\alpha"\\
\verb"ZZZ"&\to\verb"\mathbb{Z}"\\
\end{align*}
A: Mathpix is a nice tool to convert images to LaTeX: "Take a screenshot of math and paste the LaTeX into your editor, all with a single keyboard shortcut". Formulae can be taken from Internet browser, djvu-, pdf-, ... documents and even from hand-written notes.
Unfortunately now it allows to get for free only 50 formulae per month.
UPD: My antivirus killed it.

A: I'm surprised the inputenc package isn't more widely known. Simply by
putting
\usepackage[utf8]{inputenc}
into your preamble, you can directly write diacritics in your .tex file,
e.g. Poincaré instead of Poincar\'{e}, Möbius instead of M\"{o}bius, and so forth.
A: As noted by Alexey Ustinov, for portability any custom definitions may be better avoided. I find TextExpander very convenient to achieve the same functionality (a brief command that expands in a longer piece of LaTeX code) without a custom definition. In this connection I might note another functionality offered by TextExpander, which is to use LaTeX commands in any text field (chat, email, Slack, etc.) and expand symbols into their Unicode characters. The macros for this can be downloaded from the TextExpander site. You can specify which applications should use the Unicode expansions and which should leave the bare LaTeX command, so that this approach does not interfere with the usual work flow when an application understands LaTeX.
A: Take a look at this repo called tikzplotlib, it can convert plots that are generated by Python using matplotlib to tikz graphs. For example, I can draw complex plots using Python, and call the function tikz_save and save it as a .tex file, and use input{<filename>.tex} to include it in the $\LaTeX\space$ document. The graphs are prettier and more customizable.
It definitely saved me three days doing my Calculus homework
Update:
Like @Horror Vacui said, now tikzplotlib can convert to pgfplots, and it's easier to plot pgfplots directly in latex.
At the time when I first posted this answer, this package is still called matplotlib2tikz and it didn't support conversion to pgfplots.
A: Related to the question. I showed the following web-pages to a table-neighbor at a conference and literally got the "You just saved 3 days of my life" reaction.
Doi2Bib
ISBN2Bib
Arxiv2Bib
These web-sites are exactly as described: given say a DOI, it produces the bibtex entry for that particular article. I use this all the time.
