4

【Question】When using "tabbing" under math mode with cases, how can I achieved the following at the same time:

(1) alignment in cases by "tabbing"

(2) over length element such as a long sentence in "tabbing" will automatically line break instead of going out of the page?

enter image description here

【Problematic CODE】

 \documentclass[12pt]{article}
 \usepackage{amsmath}
 \usepackage{tabularx}
 \begin{document}

 \begin{tabbing}
 $\begin{cases}

\= \text{trade}, \= p(\text{trade})=\dfrac{y}{v}, \= \text{when there is a long sentence in tabbing, it will break automatic instead of going out of the page}\\

\> \text{no trade}, \> p(\text{no trade})=1-\dfrac{y}{v}

 \end{cases}$
 \end{tabbing}

 \end{document}
6
  • You can not nest display environments like cases across tabbing cells!" after you get ! Extra }, or forgotten $. then any output that you may get from tex is entirely accidental and unplanned. Commented Oct 11, 2015 at 20:28
  • So manual indentation is the only way to achieve alignment in cases? Forget about cases, can tabbing achieve auto line break in math mode (text mode)?
    – Howard
    Commented Oct 11, 2015 at 20:34
  • Why do you want to use tabbing ? In over 25 years of latex use I have never seen occasion to use it. Commented Oct 11, 2015 at 20:35
  • Thought tabbing can achieve a more freely alignment. The spaces between cells in the first row tend to be affected easily by the elements put in the second row. Say if the element is a bit longer in the second row, it will increase the entire space between columns and the original spaces between adjacent cells in the first row will increase.
    – Howard
    Commented Oct 11, 2015 at 20:43
  • Howard just like tabular, it doesn't ever increase space between cells, it just enlarges all cells in a column to match the largest. It's almost always easier to use tabular. Commented Oct 11, 2015 at 20:54

2 Answers 2

2

With tabbing you can't have automatic break of lines: you always have to specify a paragraph width for this (explicitly or computed).

Since this appears much like a math display, I suggest using cases alone:

\documentclass[12pt]{article}
\usepackage{amsmath}

\usepackage{lipsum} % for mock text

\begin{document}

\lipsum*[2]
\[
\begin{cases}
\text{trade}, & p(\text{trade})=\dfrac{y}{v},\ %
  \parbox[t]{.6\displaywidth}{
    when there is a long sentence in tabbing, it will break
    automatically instead of going out of the page
  }
\\ \\[-1ex]
\text{no trade}, & p(\text{no trade})=1-\dfrac{y}{v}
\end{cases}
\]
\lipsum[3]

\end{document}

The empty line with a slight compensation is the simplest thing to move the two real lines far apart from each other.

The width 0.8\displaywidth is “eye computed”.

enter image description here

1

enter image description here

 \documentclass[12pt]{article}
 \usepackage{amsmath}
 \usepackage{array}
 \begin{document}

\noindent X\dotfill X 
 \[
\left\{
\begin{tabular}{@{}l>$l<$>{\raggedright\arraybackslash}p{5cm}@{}}
trade,&  p(\text{trade})=\dfrac{y}{v},& \= when there is a long sentence in tabbing, it will break automatic instead of going out of the page\\

no trade,&p(\text{no trade})=1-\dfrac{y}{v}
\end{tabular}\right.
\]


 \end{document}

You must log in to answer this question.

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