8

I'm trying to type formula, which requires some textual comments. I perform this using \text{} command in math mode. However, word wrap doesn't work. What should I do? Code sample:

$P^1_{r,s}=\sum\limits_{i=r}^n{P(i\text{ applicant is selected and is the best})}=\sum\limits_{i=r}^n{P(i\text{ applicant is the best})*P(i\text{ is selected | is the best})}.$. 

As you can see on the screenshot, no word wrap is used and the line is cut. Thanks in advance.

enter image description here

1
  • 1
    Try using a parbox around the \text command
    – user31729
    Apr 13, 2014 at 19:33

2 Answers 2

8

I would type the formula as displayed:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\noindent Text before.
\begin{align*}
  P_{r, s}^{1}
  &= \sum_{i = r}^{n} P(\text{$i$ applicant is selected and is the best})\\
  &= \sum_{i = r}^{n} P(\text{$i$ applicant is the best}) \cdot P(\text{$i$ is selected $\mid$ is the best})
\end{align*}
Text after.

\end{document}

output1

If you want to left-align the equations, you can do the following:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\noindent Text before.
\begin{flalign*}
  P_{r, s}^{1}
  &= \sum_{i = r}^{n} P(\text{$i$ applicant is selected and is the best}) &\\
  &= \sum_{i = r}^{n} P(\text{$i$ applicant is the best}) \cdot P(\text{$i$ is selected $\mid$ is the best})
\end{flalign*}
Text after.

\end{document}

output2

1
  • Thanks, your answer is also helpful. Sorry, cannot upvote now, my rating is lower than 15. Apr 13, 2014 at 19:52
8

TeX inserts breakpoints after binary and relational operators with penalties \binoppenalty and \relpenalty. However, subformulas cannot be broken across lines. A pair of curly braces create a subformula as in the example of the question. Therefore the * does not create a breakpoint.

If you want breakpoints inside the text part of the formula, then the text can be given outside math.

The following example forces line breaks at the breakpoints by putting the examples into a too narrow minipage:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}

\begin{document}

\begin{minipage}{1mm}
$P^1_{r,s}=\sum\limits_{i=r}^n{P(i\text{ applicant is selected and is the
best})}=\sum\limits_{i=r}^n{P(i\text{ applicant is the best})*P(i\text{ is
selected | is the best})}$.
\end{minipage}

\smallskip\hrule\smallskip

% Remove subformula 
\begin{minipage}{1mm}
$P^1_{r,s}=\sum\limits_{i=r}^n{P(i\text{ applicant is selected and is the   
best})}=\sum\limits_{i=r}^n{P(i\text{ applicant is the best})}*{P(i\text{ is
selected | is the best})}$.
\end{minipage}

\smallskip\hrule\smallskip    

% Text outside math
\begin{minipage}{1mm}
$P^1_{r,s}=\sum\limits_{i=r}^n P(i$ applicant is selected and is   
the best$)=\sum\limits_{i=r}^n P(i$  applicant is the best$) * P(i$
is selected | is the best$)$.
\end{minipage}

\end{document}

Result

0

You must log in to answer this question.

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