2
\documentclass{report}
\usepackage{amsmath}
\newcommand\eqtext[1]{\hspace{1.0em}\text{#1}\hspace{1.0em}}
\begin{document}
\[x = y \eqtext{if and only if} y=x.\]
\end{document}

What should the horizontal spacing be in this situation? In my example it is 1.0em.

This is a stylistic question so I’m not sure if it belongs here.

  • 3
    I would simply use \text{ if and only if } – David Carlisle Jan 19 at 22:19
  • Personally, I’d either take David Carlisle’s advice or align the text into a column with equations above and below it. – Davislor Jan 29 at 6:24
3

I'd say that the typographically appropriate amount of whitespace around the text string depends both on the contents of the text string as well as on what comes before and after the string.

E.g., if the text string consists of "if and only if" and if the material before and after the string is as simple as x=y and y=x, an ordinary interword space is just fine:

x=y \text{ if and only if } y=x 
\text{$x=y$ if and only if $y=x$} % note: entire line is arg. of \text

If, in contrast, the math expressions before and/or after the string are a bit more complex than x=y, a bit more whitespace, say in the amount of \quad, may make the material easier to read. See, e.g., the third line of the following screenshot -- which actually contains two instances of \text, with two different amounts of whitespace.

enter image description here

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
x=y \text{ if and only if } y=x \\
\text{$x=y$ if and only if $y=x$} \\
\frac{x^2}{y^2}\ne0 \quad\text{if and only if}\quad x\ne0 \text{ and } y\ne0\\
\end{gather*}
\end{document}
  • Is it possible to edit the command so that it automatically puts a good amount of space? – simple jack Jan 20 at 2:58
  • @simplejack - Please define what you mean by "a good amount of space". (Aside: I tried to point out in my answer that what's typographically correct (or appealing) depends on (a) the text string itself, (b) the material that precedes it, and (c) the trailing material.) – Mico Jan 20 at 3:14
  • This might be a good candidate for an aligned environment. – Davislor Jan 29 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.