# LaTeX LaTeX pet peeves

#### DrClaude

Mentor
I am writing a document for my students about the proper use of $\LaTeX$. There are some things that always scorch my eyes, like improper italics [$sin(x)$] or incorrect typography of units [$128kg$].

I wonder those of you who are sticklers for typography have other pet peeves of the kind.

#### jedishrfu

Mentor
Will you publish your document here as an insight?

The Elements of Latex Style by D.R. Claude

#### DrClaude

Mentor
Will you publish your document here as an insight?
Good idea!

#### jedishrfu

Mentor
I found a few suggested items for your document:

where they mention use of appropriate white space and placing certain tags on separate lines.

http://inverseprobability.com/latexStyleGuide

where they list 10 points to follow

and this heavier style guide:

https://web.science.mq.edu.au/~rdale/resources/writingnotes/latexstyle.html

https://www.acm.org/publications/acm-latex-style-guide-3jan2017

a style guide written in Tex:

https://web.stanford.edu/class/ee364b/latex_templates/template_notes.tex

Lastly, from Journal of Statistical Software:

https://www.jstatsoft.org/pages/view/style

#### DrClaude

Mentor
@jedishrfu: Thanks, but this is not exactly what I am looking for. The first couple of links are about the formatting of the $\LaTeX$ code, while I care only about the final product.

As for the others, there is too much information in there. I want to focus on the little things that students often get wrong, but which makes it hard/unpleasant to read.

#### jedishrfu

Mentor
I mentioned these references only for you to briefly read to see if there's anything useful for your style guide.

I frequently do that when I need to find best practices for something. Often I won't like how someone boxed themselves in in trying to create the perfect style guide instead of using some commonsense. This was common for C coding styles back when C was hot, now its Java or Python...

Probably the one to look at would be:

https://web.science.mq.edu.au/~rdale/resources/writingnotes/latexstyle.html

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Oh, this is a deep pool ...

Edit: I might have the time to go through the most horrible ones when I am home. Currently I am on my phone and typing all of that LaTeX would be bothersome.

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Just out of interest. Are you only after style issues that show up when using MathJax here or more general style issues with actual LaTeX documents?

#### jedishrfu

Mentor
Just out of interest. Are you only after style issues that show up when using MathJax here or more general style issues with actual LaTeX documents?
Yes

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Which one?

Mentor

#### kith

$|\psi>$ instead of $|\psi\rangle$ hurts my eyes.

/edit: And also $(\frac{a^2}{b})$ instead of $\left(\frac{a^2}{b}\right)$. But I think that these little sins of style only stick out as much because the use of Latex usually leads to such a beautiful document overall. I am still amazed by how easy it is to produce a document with a professional look with Latex.

Last edited:

#### jedishrfu

Mentor
I think this error results from students thinking of latex as a kind of alphabet and the since they need a right bracket the automatically choose the $>$ sign. We do this on our keyboards all the time to enter an expression or formula.

One strategy might be to add these rare symbols to the top of the style guide as a kind top ten gotchas.

Actually our site has a pretty good summary of MathJax/Latex

https://www.physicsforums.com/help/latexhelp/

#### DrClaude

Mentor
Just out of interest. Are you only after style issues that show up when using MathJax here or more general style issues with actual LaTeX documents?
I'm mostly concerned with actual LaTeX documents. I'm spending lots of time right now correcting lab reports and some things keep cropping up.

#### fluidistic

Gold Member
I know at least a person annoyed when the "d" sign of the differential appearing in integrals is not straight. There's a special command to make it appear normal, but most people ignore it and so the d appears curved.

#### DrClaude

Mentor
I know at least a person annoyed when the "d" sign of the differential appearing in integrals is not straight. There's a special command to make it appear normal, but most people ignore it and so the d appears curved.
Do you mean
$$\int x \, \mathrm{d}x$$
as opposed to
$$\int x \, dx$$
?

There is no accepted standard for this, since while many (including me) argue that the former is the proper way to typeset the d, Physical Review uses the latter.

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Do you mean
$$\int x \, \mathrm{d}x$$
as opposed to
$$\int x \, dx$$
?

There is no accepted standard for this, since while many (including me) argue that the former is the proper way to typeset the d, Physical Review uses the latter.
This one I don't really care about as long as it is done consistently. What I do care about is when it is used with improper spacing so that it is not clear at all what is there...
$$\int x dx$$
Note that the LaTeX code has the required space, but a space in math mode in LaTeX is not what many people think it is.

Here is a selection of my LaTeX pet peeves. I don't think it is exhaustive but those are the ones I can think of at the moment.

Starting a new paragraph after an equation or a figure: A common mistake is to want to space out the LaTeX source around a figure or equation. What many do not realise is that if this is done carelessly, LaTeX is going to interpret this as the equation/figure forming its own paragraph due to the multiple line breaks in the source. This can be helped in the following fashion by commenting out the line breaks:
Incorrect:
Code:
bla bla bla

*Equation/Figure code*

bla bla bla
Correct:
Code:
bla bla bla
%
*Equation/Figure code*
%
bla bla bla
Sure, there are some times when you might want to actually end your paragraph with an equation, then go ahead. However, this should be done consciously, not by accident.

Using different symbols in math mode and text: Yes, those dollar signs are annoying to type out, but not including them is a certain way to make sure your report looks unprofessional. It is ugly and confusing and some symbols really look different in regular text and in the math mode italic.

Incorrect:
Einstein found out that
$$E = mc^2,$$
where E is the energy, m is the mass, and c is the speed of light in vacuum.

Correct:
Einstein found out that
$$E = mc^2,$$
where $E$ is the energy, $m$ is the mass, and $c$ is the speed of light in vacuum.

Using relations as delimiters: It has already been mentioned in this thread. In particular the bra-kets used in quantum mechanics. < and > in LaTeX are relations and are typset as such, with spacings appropriate for relations, such as $1 < 2$. This is not to be used for bras or kets $|1> |2>$ (note the horrible spacing - this is practically unreadable to me without getting a headache). The appropriate delimiters to use in this case are \langle and \rangle, $|1\rangle$ or $\langle 2|$. Alternatively, < and > do become delimiters when used in conjunction with \left and \right.

Not using proper spacing after abbreviations: My PhD student thinks I have an uncanny sense for this one when correcting texts. LaTeX interprets periods as the end of a sentence and typsets the spacing accordingly, slightly longer than the spacing between words. However, LaTeX does not inherently know when your period is just the period noting an abbreviation such as e.g., i.e., etc. (Note that the period at the end of etc. is serving double duty as a period in that sentence! Do not double period abbreviations at the end of a sentence.) This can be corrected by telling LaTeX to use the appropriate spacing explicitly. A regular spacing is just a backslash followed by whitespace (\ ).

Not making sure line breaks are not in the middle of expressions that naturally should not line break: "Fig.
3". LaTeX does not know that your space after Fig. is not just a regular space where it can line break at will. Tell it that you will have none of it by using a non-breaking space (~). This goes for things like equation numbers (Eq. (3)), figure numbers (Fig. 4), or units (241 kg).

Not using proper spacing between numerical values and units: 1.23cm versus 1.23 cm. The appropriate typesetting is with a space. Also see the previous point not to mess up the line breaks!

Typesetting units in math mode: Units are not mathematical symbols. Do not typeset them as such. In running text, do not even enter math mode if you are just writing a number. End math mode after the number if it is part of an equation: $\ell = 2.32$ cm. (Don't forget the non-breaking space between ending math mode and the unit!) Inside a displayed equation, use a ~ to get the appropriate spacing and then use an \mbox or \rm for the units. Do not forget to separate units by a small space:
$$100~\mbox{kgm/s} \quad \mbox{vs} \quad 100~\mbox{kg}\,\mbox{m/s} \quad \mbox{or} \quad 100~\mbox{kg m/s}$$
(preferably the middle one).

Temperature confusions: Put the $\circ$ in the correct place. This includes not putting it at all when you are using Kelvin as your temperature unit. Wrong:
$$90^\circ\mbox{C},\ 45^\circ~\mbox{C},\ 30~^\circ\mbox{K}$$
(The middle one technically says "45 angular degrees Coulomb" ...)
Correct:
$$90~^\circ\mbox{C},\ 30~\mbox{K}$$

Improper use of minus signs, dashes, etc: Sure, you want to write the x-y-plane and you want to follow the rule that x and y need to be typeset in math mode, but for Heaven's sake, typeset the dash in between in regular text or it becomes a minus sign (which is also an operator and will be typeset as such with the spacings appropriate for that). Compare:
$$\mbox{x-y-plane} \quad \mbox{to} \quad \mbox{x-y-plane.}$$
(Or consistently use $xy$-plane instead ...)
Also double check your usage of dashes (-) versus N-dashes (--) and M-dashes (---) and use the appropriate ones. For example, typically double names in things that are named after people in sciences (e.g., Levi-Civita) are separated by a regular dash whereas multiple different names (e.g., Robertson-Walker) would be separated by an N-dash. (My proof-reader thought Levi-Civita should go with an N-dash and consistently marked this, I told him otherwise.)

Improper spacing in equation arrays, aligns, etc.: Most math environments have a particular way in which they need to be used in order to get the appropriate spacing.
\begin{align*}
E = &B(a+b)
\end{align*}
Note how the = is closer to the $B$ than to the $E$. This is not correct spacing.

Too long equations: In particular those where your equations overflow to the point of overwriting the equation number. You can line break an equation!

Overfull hboxes: Need I say more? A few pts, fine. But if your hboxes overflow by 234 pts it is going to look awful ...

Well, I don't think it is exhaustive but I am getting tired ...

#### jedishrfu

Mentor
I like the second one for aesthetics.

#### kuruman

Homework Helper
Gold Member
Spaces before unit vectors
$$\hat r =\cos\theta ~\hat x+\sin\theta~\hat y~ \quad \mbox{vs}~\quad \hat r =\cos\theta \hat x+\sin\theta\hat y$$

Spaces after unit vectors
$$\vec E\cdot \hat n~dS~ \quad \mbox{vs}~\quad \vec E\cdot \hat ndS$$

Dots in units
$$100~\mbox{N} \cdot \mbox{m} ~ \quad \mbox{vs} \quad 100~\mbox{N m}$$

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Spaces before unit vectors
$$\hat r =\cos\theta ~\hat x+\sin\theta~\hat y~ \quad \mbox{vs}~\quad \hat r =\cos\theta \hat x+\sin\theta\hat y$$
This is related another general issue. Namely using parentheses for functions like $\sin$ and $\cos$, in particular when followed by other symbols that are not part of the argument:
$$\sin\theta x \quad \mbox{vs} \quad \sin(\theta) x \ \mbox{or}\ x\sin\theta$$
Note that $x\sin\theta$ is correctly spaced in front, whereas $xsin\theta$ is not.

Spaces after unit vectors
$$\vec E\cdot \hat n~dS~ \quad \mbox{vs}~\quad \vec E\cdot \hat ndS$$
I would probably not put such large spacing ($\hat n\,dS$ versus $\hat n~dS$), but I also think it is related to the spacing to differentials.

Dots in units
$$100~\mbox{N} \cdot \mbox{m} ~ \quad \mbox{vs} \quad 100~\mbox{N m}$$
Same here, I would use $100~{\rm N\,m}$ rather than $100~\mbox{N m}$, but yes I agree.

### The Physics Forums Way

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving