我有一系列 TeX 公式,其中作者在文本中放入了空格,例如:
{\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}}}
使用pdfTeX,文本呈现时不包含空格:
我需要对 TeX 公式做什么才能显示空格?
答案1
我建议你\text
对不需要换行的 2 个字符串使用说明,\parbox
对需要换行的 2 个字符串使用指令。\text
和都\parbox
以文本模式排版其参数,这正是你想要的。
备注:正如@barbarabeeton 在评论中指出的那样,如果这种类型的“冗长的等式”有可能出现在以斜体为主要字体形状的环境中(例如,类似定理的环境内部),则应使用\textup
或\textrm
代替,\text
以确保使用直立字符而不是斜体字符。
\parboxes
对于下面的示例代码,我经过最少的反复试验后选择了宽度。
\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}
答案2
答案3
如果您正在使用 LaTeX,请注意它\rm
在大约 30 年前就已被宣布过时并被弃用。
您应该使用它tabular
来完成这项工作,这样您就不需要猜测材料的宽度了。
\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}
如果您使用的是纯 TeX,则可以用类似的方式完成。
\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