×

# PSA #1

When writing in LaTeX, never ever ever write like this:

$\overset { \rightarrow }{ { F }_{ e } } ={ k }_{ e }\dfrac { { q }_{ 1 }{ q }_{ 2 } }{ { r }^{ 2 } } \overset { \wedge }{ r }$

The above was "expressed" as

\overset { \rightarrow  }{ { F }_{ e } } ={ k }_{ e }\dfrac { { q }_{ 1 }{ q }_{ 2 } }{ { r }^{ 2 } } \overset { \wedge  }{ r }


Well, you might ask, it looks alright to me. Doesn't really matter what the innards are, just as long as the final product is digestible.

WRONG.

The issue with sloppy LaTeX writing is twofold: 1. people cannot learn from your LaTeX; and 2. it is much harder to check your work for mistakes, or to "debug" it. If I wrote

\overset { \rightarrow  }{ { F }_{ e } } ={ k }_{ e }\dfrac { { { q }_{ 1 }{ q }_{ 2 } }{ { r }^{ 2 } } \overset { \wedge  }{ r }


it will not be a valid LaTeX input, and it would take ages to track down the mistake(s), however minute.

Here are a few guidelines to help you become a better LaTeXian/ist/er.

Guideline 1: Don't use spaces unless they are a necessity, around equals signs, or within long expressions to signify terms/sub-expressions.

Compare this:

\overset { \rightarrow  }{ { F }_{ e } } ={ k }_{ e }\dfrac { { { q }_{ 1 }{ q }_{ 2 } }{ { r }^{ 2 } } \overset { \wedge  }{ r }


to this:

\overset{\rightarrow}{{F}_{e}} = {k}_{e} \dfrac{{{q}_{1}{q}_{2}}{{r}^{2}} \overset{\wedge}{r}


Much neater.

(Some would write

\overset{\rightarrow}{{F}_{e}} = {k}_{e}\dfrac{{{q}_{1}{q}_{2}}{{r}^{2}}\overset{\wedge}{r}


instead [notice that spaces have been removed before \dfrac and \overset]; this is a matter of taste. The guideline here is to minimise spacing, essentially.)

Guideline 2: Don't use braces unless they are a necessity.

Compare this:

\overset{\rightarrow}{{F}_{e}} = {k}_{e} \dfrac{{{q}_{1}{q}_{2}}{{r}^{2}} \overset{\wedge}{r}


to this:

\overset{\rightarrow}{F_e} = k_e \dfrac{q_1q_2}{r^2} \overset{\wedge}{r}


Again, a drastic improvement in cleanliness.

Guideline 3: Look for shortcuts/features to make your life easier.

We may use \vec{} and \hat{} rather than the cumbersome \overset{}{} to obtain at once a more concise and illuminating LaTeX input. Compare this:

\overset{\rightarrow}{F_e} = k_e \dfrac{q_1q_2}{r^2} \overset{\wedge}{r}


to this:

\vec{F_e} = k_e \dfrac{q_1q_2}{r^2} \hat{r}


Not only that, $$\overset{\wedge}{r}$$ and $$\hat{r}$$ differ in that the latter is surely recognised as the notation for unit vectors, which the former may be confusing to readers.

(This is especially important when it comes to LaTeX formatting, where you can set shortcuts. I personally use \conj{}, \mean{}, etc to mean the conjugate, the sample mean, etc, while in practice they are still equivalent to \overline{}. This is for readability's/checking's sake.)

Now, putting this altogether, we have

$\vec{F_e} = k_e \dfrac{q_1q_2}{r^2} \hat{r}$

which is not only equivalent to what we want, but also elegant, legible and efficient.

Other guidelines:

Stay consistent. For example, stick to the order in which you input _ and ^ (subscript and superscript). Most people do the former first, followed by the latter.

Take care not to make mistakes like $$n^10$$ instead of $$n^{10}$$.

[WIP?]

Examples:

{ \int}_{ 0 }^{ \infty  }e^{- x^{  2 }_{ 0 } } \  d x_{ 0}=\frac { \sqrt{ \pi } }{ 2}


vs

\int_0^\infty e^{-x_0^2} \ dx_0 = \frac{\sqrt{\pi}}{2}


[also WIP]

PS If any of the mods touch this I'll skin you. Another friendly PSA by Jake.

Note by Jake Lai
8 months, 3 weeks ago

Sort by:

This is exactly what i think! It is so hard to edit stuff with unnecessary {}. Thanks for posting this note jake! · 8 months, 2 weeks ago

Cool! I hope people won't make such mistakes in future. · 8 months, 3 weeks ago

They aren't mistakes, inasmuch as bad habits. · 8 months, 3 weeks ago

how much time did you take to design this note ? · 8 months, 2 weeks ago

About 20 minutes, I think. · 8 months, 2 weeks ago

×