12

Like for example, if I have:

For example when I use the double quotes and make everything center and bigger, I can't really type sentences or anything, because it all comes together:

x = 4 or x = 5

becomes

$$ x=4 or x=5$$ See how the 'or' is squished? How do I space it out?

5
  • I don't know why it didn't show up ... but yeah I think you get the point
    – K Split X
    Commented Dec 12, 2016 at 17:02
  • 12
    the "or" should be treated as text: \text{ or }, with the spaces inside the text string. also, better to use \[ ... \] than $$ ... $$ -- see Why is \[ … \] preferable to $$? Commented Dec 12, 2016 at 17:02
  • Thank you, and do you know why it doesn't show up? When I'm on mathoverflow and stuff the formatting works, here it doesnt show?
    – K Split X
    Commented Dec 12, 2016 at 17:03
  • 3
    in this forum, we prefer to see the input code, since that's where the problems are found. a visual example of the output can be prepared using the methods described here: Compile a LaTeX document into a PNG image that's as short as possible Commented Dec 12, 2016 at 17:06
  • 2
    @KracX - Math.SE and similar sites use MathJax. The syntax may look similar to LaTeX, but the underlying engine is completely different.
    – Mico
    Commented Dec 12, 2016 at 17:07

2 Answers 2

15

This has already been answered in the comments but let's go right on ahead and provide a full answer down here.

For our purposes, LaTeX has three modes: math mode, paragraph mode and left-to-right mode (LR mode).

In math mode, LaTeX treats everything as maths. It doesn't know that or is a word, it just treats it as maths. What this means is that Roman (as in the Roman or Latin alphabet we use in English) letters are set in italics by default. A string of Roman letters abc is treated as a string of variables, a, b and c, multiplied together. This is normally what you want with maths, right? If you have ab you usually mean the variable a times the variable b.

Now, if I write or, LaTeX doesn't know that's the English word "or", it just treats it as the variable o times the variable r.

Next thing: spacing in math mode is handled automatically - and very smartly - by TeX. White space in the input is ignored in the output:

a b    cd        e   f

And

abcdef

Produce the same result. (The spacing around these letters will be suitable for a string of variables being multiplied as we discussed above.)

Spacing around operators and relations such as \sin, \log, +, -, =, \in and so on is all done for you.

x\sin x+d=4

And

x    \sin x+      d     = 4

Will produce the same result, with the appropriate spacing around the sin the + and the =.

So what do you do if you want to have some text in math mode, including proper spaces around the text?

The simplest way is to be sure to load the amsmath package and use the \text{} command. This, I believe, puts us in LR mode, but it doesn't really matter for our purposes, what it means is that LaTeX is back to treating things as text! or is now taken to be a word, one or more spaces in the input produces a space in the output.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
  x = 4 \text{ or } x = 5
\]

\end{document}

enter image description here

Finally, there are two types of math mode. Display math mode is used for displaying equations, they will be centred, there will be a skip above and below to visually separate them, large operators like \sum will appear large and limits will generally be set above and below the operator. In TeX, display math mode was accessed by $$ ... $$, but in LaTeX, we prefer \[ ... \].

3
  • I often want more space around words in equations like this. In such cases I use either \qquad\text{ or }\qquad or \quad\text{ or }\quad.
    – user30471
    Commented Dec 12, 2016 at 22:40
  • @Andrew Good point, I'd add it in, but I don't think it would fit so well in mine. A second answer focusing on general spacing commands in math mode, however, would be a wonderful complement - or I guess there must be an answer somewhere on here already if you'd rather add a link? :)
    – Au101
    Commented Dec 12, 2016 at 22:45
  • 1
    I suspect that it is partly a matter of personal taste (and so should be avoided!). I don't think that I am qualified to write a general answer about spacing math-mode:) Happy to leave this as a comment.
    – user30471
    Commented Dec 12, 2016 at 22:47
3

I would always prefer something like

\[ 
\text{$x=4$ or $x=5$} 
\]

since it handles the spacing around the or correctly (hacking around with \quad and friends rarely does).

2
  • 1
    But be careful, this probably gives you the in-line size for math symbols (such as integral signs), which might come out too small compared to displayed equations. Commented Dec 13, 2016 at 15:00
  • Good point, if this is an issue then \displaystyle is your friend
    – J.J. Green
    Commented Dec 13, 2016 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .