3

Imagine you intend to have "x=" in your document, followed by something that cannot be rendered in math mode, nor within some sort of box within math mode. Is there a preferred way to treat the right operand of the equals sign? Perhaps one of the following?

$x=$ something
$x={}$ something
$x=\mathord{}$ something
$x=\mathstrut$ something

or any of the above without the space between the closing dollar sign and the 's'? Or just go with whatever looks good to you?

So far I've been going with

$x={}$something

But it was suggested to me that this is a hack, and that maybe

$x=\mathstrut$something

would be preferred.

6
  • 3
    You have \text{} to insert in math mode, but if it is impossible to insert something in math, then the first is the closest one. Without too much effort.
    – AboAmmar
    Commented Jul 23, 2015 at 4:50
  • OK, so it's $x=$ something and definitely not $x=$something. I had some automated LaTeX stuff going on where the space after closing math mode was not automatically generated. It looked bad, so that's when I started putting empty right operands in there. But it turns out I just need a space character after closing math mode. Commented Jul 23, 2015 at 7:16
  • @AboAmmar But there is still a slight difference between $x=$ something and $x={}$something. Is it a sure thing that the former is better? To my understanding the latter is actually balancing space around the equals sign better. Commented Jul 23, 2015 at 7:19
  • Also, when something is just the word "something", and so therefore insertible within the math mode, then $x={}$something seems to agree with $x=\text{something}$ whereas $x=$ something does not. Commented Jul 23, 2015 at 7:22
  • Please, give more information about cannot be rendered in math mode. In may cases it is possible to insert some textual content inside a math mode using some special tricks and then you can keep all the math structure preserved.
    – Sigur
    Commented Jul 23, 2015 at 7:46

1 Answer 1

6

A picture is worth a thousand words:

enter image description here

I have attached a picture alongside its generating code for comparison. You can click on the image for a bigger view (nice feature new to TeX.SX). Paying a close look, you observe a perfect alignment between first and fourth expressions where both come from mathmode. The second nearest is the third, then comes the second the fifth and the sixth (which are all the same). But a big difference between the second and the third exists. If I can't follow the fourth, I would follow the third!

10
  • 4
    I don't think this picture is worth a thousand words. Why not $x={}$something?
    – Manuel
    Commented Jul 23, 2015 at 8:14
  • 2
    Wouldn't the space in the third option $x=$ something depend on the paragraph formatting? I mean, it's just an interword space in text mode, so it can be modified, no? I think that @Manuel suggestion is the best one.
    – Rmano
    Commented Jul 23, 2015 at 9:16
  • $x=\text{something}$ is the right thing to go for (or also $x=\mbox{something}$, in a case like this). In “normal” circumstances, @Manuel’s suggestion $x={}$something$ yields exactly the same result, as you can check with \showlists, but beware of \mathsurround.
    – GuM
    Commented Jul 23, 2015 at 13:07
  • 2
    @GustavoMezzetti Apart from \mathsurround which is usually of no problem, the benefit of leaving something outside of math mode (technically outside of a box) is that it can be hyphenated, and for instance it can stretch or shrink a little bit with microtype.
    – Manuel
    Commented Jul 23, 2015 at 14:19
  • 1
    @Manuel (Please do not think I’m too fussy, but in the interest of exactitude): It occured to me that, in $x={}$something, actually the word “something” cannot be hyphenated, because it does not follow a glue item (see Appendix H, p. 454, first sentence of second double dangerous bend). You can check this with \showhyphens. EDIT: but of course you can apply the usual trick of adding \nobreak\hskip 0pt \relax.
    – GuM
    Commented Jul 24, 2015 at 0:23

You must log in to answer this question.

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