【问题】在数学模式下使用“制表符”功能时,如何同时实现以下功能:
(1)通过“Tab 键”对齐案例
(2)超长元素,比如“制表”中的长句子,是否会自动换行,而不是超出页面范围?
【有问题的代码】
\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}
答案1
由于tabbing
您无法自动换行:因此您始终必须为此指定段落宽度(明确或计算)。
由于这看起来很像数学显示,我建议cases
单独使用:
\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}
带有轻微补偿的空线是使两条实线彼此远离的最简单的方法。
宽度0.8\displaywidth
是“用眼睛计算的”。
答案2
\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}