6

I have a series of TeX formulas where the author has put in spaces in the text, for example:

{\rm{Maximum credit}} = {{\mathop {{\rm{Net income from sources}}}\limits_{{\rm{without the United States}}} } \over {{\rm{Total net income}}}} \times \mathop {{\rm{United States tax on}}}\limits_{{\rm{total income}}}

Using pdfTeX, this gets rendered without the spaces in the text:

Enter image description here

What do I need to do to the TeX formula to get the spaces to show?

CJ7
  • 161
  • 2

3 Answers3

8

I suggest you use \text instructions for the 2 strings that don't need line breaking and \parbox directives for the 2 strings that do. Both \text and \parbox typeset their arguments in text mode, which is precisely what you want.

Remark: As @barbarabeeton has noted in a comment, if there's any chance at all that this type of "wordy equation" will occur in a setting that employs italics as the main font shape (such as the interior of a theorem-like environment), you should use \textup or \textrm instead of \text in order to assure that upright rather than italic characters are used.

For the following example code, I chose the widths of the \parboxes after a minimal amount of trial and error.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for '\text' macro
\begin{document}

[ \text{Maximum credit} = \frac{\parbox{4cm}{\centering Net income from sources without the United States\strut}}{% \text{Total net income}} \times \parbox{2.75cm}{\centering United States tax on total income} ]

\end{document}

Mico
  • 506,678
  • Might want to specify \textup or \textrm instead of just plain \text. If this happens to be located within a block of italic text (e.g., a theorem), just plain \text would follow the appearance of the environment. – barbara beeton Nov 18 '21 at 01:57
  • Thanks, @barbarabeeton. I've added a paragraph to give the gist of your comment the visibility it deserves. – Mico Nov 18 '21 at 02:14
6
  • Load the amsmath package (or mathtools which also loads amsmath).
  • The amsmath package offers the function \text{}.
  • The \text{} function is intended to be used within math and respects spaces, e. g. \text{Net income from sources}.
  • Alternatively, use ~ to create spaces, e. g. \mathrm{without~the~United~States}. Please be aware that I changed \rm to \mathrm since this is the more appropriate command, see here. See here for alternatives to ~.
2

If you're using LaTeX, be advised that \rm has been declared obsolete and deprecated about 30 years ago.

You should use instead tabular for the job, with which you don't need to guess the width of the material.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\wordvar}[1]{% \textup{\begin{tabular}{@{}c@{}}#1\end{tabular}}% }

\begin{document}

[ \wordvar{Maximum credit} = \frac{\wordvar{Net income from sources \ without the United States}} {\wordvar{Total net income}} \times \wordvar{United States tax on \ total income} ]

\end{document}

enter image description here

If you're using plain TeX, it can be done in a similar way.

\def\wordvar#1{%
  \vcenter{\rm\ialign{\hfil\strut##\hfil\cr#1\crcr}}%
}

$$ \wordvar{Maximum credit} = { \wordvar{Net income from sources \cr without the United States} \over \wordvar{Total net income} } \times \wordvar{United States tax on \cr total income} $$

\bye

egreg
  • 1,121,712