The discussion focuses on common typographical errors in LaTeX documents that hinder readability, particularly for students. Key issues include improper use of italics, incorrect spacing between numbers and units, and the use of symbols inappropriately, such as using relational symbols instead of proper delimiters in mathematical expressions. Participants emphasize the importance of consistent formatting, such as ensuring proper spacing after abbreviations and avoiding line breaks in the middle of expressions. Overall, the conversation highlights the need for a style guide that addresses these common pitfalls to improve the quality of LaTeX documents.
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.
(Somehow, I think that @Orodruin might have something to say about this )
@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.
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...
Somehow, I think that @Orodruin might have something to say about this
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.
/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.
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
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.
#15
fluidistic
Gold Member
3,928
272
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.
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.
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 realize 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 ...
Using Word to typeset your equations instead of LaTeX: Just don't.
Well, I don't think it is exhaustive but I am getting tired ...
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.
Related to the ##|\psi\rangle## one, I myself perpetrated ##\epsilon << 1## before realising you could do ##\epsilon\ll 1##, which looks so much better.
@Orodruin: Thanks! You pointed out many interesting common mistakes.
Orodruin said:
What I do care about is when it is used with improper spacing so that it is not clear at all what is there...
Notice that in my post above I had added the space
Orodruin said:
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.
I see this less often with figures, as people don't always include figures as part of the text. This is especially bad when the style puts an indentation at the beginning of a new paragraph.
Orodruin said:
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.
That bothers me a lot too. I have also seen instances where only part of an equation is within the dollar signs, something like x = ##y^2##.
Orodruin said:
Not using proper spacing after abbreviations:
I have had also the inverse problem. When dealing with chemical elements, a sentence can end in a chemical symbol followed by a period. LaTeX will then interpret this as an abbreviation and not use the correct end-of-sentence spacing, so one has to add \@
Code:
as is the case for HCN.\@ We can also see that
Orodruin said:
Not using proper spacing between numerical values and units:
Units are a big source of error. There is the spacing, the font type, how to deal with compound units... I recommend the package siunitx, which makes it easy to get the units right without much effort.
Orodruin said:
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.
It's sad that amslatex botched that one. They do provide better alignment with align then the native eqnarray, but they didn't provide proper support for the case where the rhs must be broken up.
Orodruin said:
Using Word to typeset your equations instead of LaTeX: Just don't.
Friends don't let friends use Word.
Orodruin said:
Well, I don't think it is exhaustive but I am getting tired ...
Not exhaustive but exhausting? Thanks again!
#23
member 587159
Using ##\delta## instead of ##\partial##
Using ##<## instead of ##\langle##
Not matching the bracket size with its argument.
I agree, but it can also be problematic. For instance, I think that the following is incorrect
$$
\left\langle \psi \left| \frac{\hat{p}^2}{2m} \right| \psi \right\rangle
$$
and should be
$$
\left\langle \psi \right| \frac{\hat{p}^2}{2m} \left| \psi \right\rangle
$$
I agree, but it can also be problematic. For instance, I think that the following is incorrect
$$
\left\langle \psi \left| \frac{\hat{p}^2}{2m} \right| \psi \right\rangle
$$
and should be
$$
\left\langle \psi \right| \frac{\hat{p}^2}{2m} \left| \psi \right\rangle
$$
I think this is more of a style choice issue to be honest.
Math_QED said:
Using ##\delta## instead of ##\partial##
Or using ##\partial## instead of ##\delta## or ##d## ...
One of my common ##\LaTeX## constructs for units is
Code:
\vec g= - 9.8{\rm\ m/s^2}\ \hat y %preferred
\vec g= - 9.8\ m/s^2\ \hat y
\vec g= - 9.8{\rm\ m/s^2}\ \hat y %preferred
vs.
\vec g= - 9.8\ m/s^2\ \hat y
With an " \mbox{} ", I can't use superscripts or subscripts easily..
(When I use Microsoft Word with MathType 6.9, I have a customized button for the units.
[By the way, I'm annoyed that MathType 7 is now subscription-based.]
)
Yes, I also hate "[short] hyphens" as minus signs:
3 + (-4) = -1 [ok]
vs
3 + (-4) = -1 [great]
vs
\mbox{3 + (-4) = -1} [not ok]
Recently, I prefer bold-nonitalicized vectors with arrowheads.
So I have macros (when I use ##{\TeX}studio## or Overleaf):
I also prefer non-italicized subscripts for words:
Code:
\VEC F_{\scriptsize{\mbox{net on dog}}}
\VEC F_{net\ on\ dog}
\VEC F_{\scriptsize{\mbox{net on dog}}}
vs
\VEC F_{net\ on\ dog}
(Maybe I should make a macro for that.)
Macros are good, in case I change my mind later.
In addition, they represent logical constructions in the composition,
rather than just strings of text in the source or in the rendered image.
Speaking of vectors, if you are going to use any character decorators (arrows, hats, etc), don't include subscripts "under" the decorator. It seems arguable to me with a one letter subscript (e.g. ##\vec {v_x}## vs ##\vec v_x##), but with a longer one it looks like ##\vec{v_{xyzabc}}##, for which I definitely prefer ##\vec v_{xyzabc}##.
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}
$$
I disagree with this one. I know the standard is technically supposed to be this:
$$
90~^\circ\mbox{C}
$$
However, I just find this to be much better aesthetically:
$$
90^\circ\mbox{C}
$$
(I'm not alone in that either - Oxford, the University of Chicago, and UCAR all follow this convention)
I disagree with this one. I know the standard is technically supposed to be this:
$$
90~^\circ\mbox{C}
$$
However, I just find this to be much better aesthetically:
$$
90^\circ\mbox{C}
$$
(I'm not alone in that either - Oxford, the University of Chicago, and UCAR all follow this convention)
That someone else refuses to abide by standards (even if they are professional publishers or organisations) is not a good excuse not to abide by standards in my opinion. Regardless of how you find it aesthetically (especially if your aesthetics are off as in this case ).
Use \par not \\ outside of some kind of environment that specifically makes use of \\, e.g align. Can also use a blank line in the code.
Use \left \right to scale parentheses
Prepare your preamble, if you need to change how something looks, you can do so in the preamble. Seen so many beginner students manually enumerating their sections, subsections or doing spacings between sections .
Well as I am using it only for legibility in homework help, perfectionism beyond a certain point I cannot justify more investment of time in, though I try up to that point. When you write ln and other function abbreviations you want it italics ##ln##. But I could only get it in certain positions here, but in others I couldn't, got something else, red color.
That someone else refuses to abide by standards (even if they are professional publishers or organisations) is not a good excuse not to abide by standards in my opinion. Regardless of how you find it aesthetically (especially if your aesthetics are off as in this case ).
The fact that it's used by professional publishers and organizations makes it a different standard though, not nonstandard
This is kind of a rehash, but I'm not sure how firm the grounds are for some differences. Pure opinion, tradition in your field? I think it is more the former for some of these choices. And I cannot get a grip on why for some of them.
Here is one example:
How about Abramowitz and Stegun - Handbook of Mathematical Functions? Pretty standard resource, IMO. My father's calculus book from 1931 use the same typeface as A&S.
Check out Page X, Sec 3 'Auxillary Functions and Arguments'
One of these gives @DrClaude headaches.
##\int x \, \mathrm{d}x## versus ##\int x \, dx##
... they use very one @DrClaude does not approve of. I cannot copy it very well, you may want to consider verifying what I said directly. I get that paradigms may change, but I think you need to consider that older standard resources may have a different take on what is/was correct. I do not know of an "ANSI standard" for Latex use. Please advise me if one exists. These guys do not know of one, either. See accepted answer: https://tex.stackexchange.com/questions/275330/is-there-a-language-standard-iso-ansi-for-latex
Last edited:
#36
fluidistic
Gold Member
3,928
272
For units I suggest the use of siunitx package. It is powerful and complete, sticks with some convention(s). From it I learned that when using a range such as "from 9 to 15 K" is incorrect. The correct way to write it is by using the unit on both values.
I recommend the package siunitx, which makes it easy to get the units right without much effort.
fluidistic said:
For units I suggest the use of siunitx package.
I can also endorse this package.
#38
greypilgrim
579
44
Orodruin said:
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.
Are you sure about this? You certainly need math mode if the unit contains fractions or exponents. Why not consistently use it? Also, I think you should never use math mode for only part of an equation, even if it doesn't make a visible difference in this case.
Actually, while it might not make a visible difference in a document, it certainly does in this forum, as the fonts are different.
##\ell=2.32## cm is certainly worse than ##\ell=2.32~\mbox{cm}##.
I am not saying you should not include the unit in math mode. I am saying you should not typeset it in standard math mode, but use some way of typesetting it in your regular font. There are several ways of doing this that produce acceptable results.
greypilgrim said:
it certainly does in this forum, as the fonts are different.
This thread is not about the forum, but about a typical LaTeX document, as stated by OP.
DrClaude said:
I'm mostly concerned with actual LaTeX documents.
I also disagree with ##\ell = 2.32## cm being worse in forum form than ##\ell = 2.32~{\rm cm}##, but that is more a matter of taste.
#40
greypilgrim
579
44
Orodruin said:
I am not saying you should not include the unit in math mode.
Actually you did say (and do) just that:
Orodruin said:
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.
But alright, in the end it only matters how it looks in the processed document.
Another one, while not ##\LaTeX## per se, is the use of computer notation for powers of ten:
$$
V_0 = 1e-5
$$
instead of
$$
V_0 = 1\times 10^{-5}
$$
or
$$
V_0 = 10^{-5}
$$
I've also seen the inverse in code, something like
Adding to the list: not entering accented characters properly.
This doesn't appear to be a problem with MathJax, but in regular ##\LaTeX##, a word such as Schrödinger entered as is will render as
##\text{Schrdinger}##.
One has to use, e.g., \"o or to use the inputenc package to allow for extended ASCII characters: