我正在尝试对齐统计分析中使用的各种变量的描述列表。如果相关的话,单列的文本宽度为 75 毫米。
我尝试了各种环境(tabular、tabularx),但没有好的解决方案。我目前最好的方法是
Mauris suscipit risus dapibus urna
fermentum, sed placerat leo tincidunt.
Vivamus sit amet laoreet ante.
Nulla in egestas turpis.
\vspace{-9mm}%
\begin{list}{}
\item
\begin{equation*}
y =
\begin{cases}
1 & \textrm{condition for variable to be unity} \\
0 & \textrm{condition for variable to be zero} \\[+1.5mm]
\end{cases}
\end{equation*}
%
\item{$x_1$}
= very long description with lots of words of the first $x$ variable
%
\item{$x_2$}
= very long description with lots of words of the second $x$ variable.
%
\end{list}
\vspace{2mm}\noindent
Aenean consequat sapien venenatis,
sollicitudin tellus nec,
sollicitudin lectus.
Curabitur eget pulvinar justo.
这样可以对齐列表的左边缘,也许运气好的话,等号 (=) 也会对齐,但会将后续行放在项目描述的开头下方,而不是缩进。此外,还需要对垂直间距进行过多的手动调整,这也非常不美观!
请提出建议...
答案1
quote
以下示例使用了修改后的环境、包tabularx
和array
的组合booktabs
:
\documentclass[twocolumn, a4paper]{article}
\usepackage[
columnsep=5mm,
textwidth=155mm,
]{geometry}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\newenvironment{leftquote}{%
\list{}{}%
\item\relax
}{%
\endlist
}
\newenvironment{vardesc}{%
\newcommand*{\nextvar}{%
\tabularnewline
\addlinespace
}%
\leftquote
\tabularx{\linewidth}{@{}>{$}l<{$}@{${}={}$}X@{}}%
}{%
\endtabularx
\endleftquote
}
\begin{document}
Mauris suscipit risus dapibus urna
fermentum, sed placerat leo tincidunt.
Vivamus sit amet laoreet ante.
Nulla in egestas turpis.
\begin{vardesc}
y &
$\begin{cases}
1 & \textrm{condition for variable to be unity} \\
0 & \textrm{condition for variable to be zero}
\end{cases}$
\nextvar
x_1 &
very long description with lots of words of the first $x$ variable.
\nextvar
x_2 &
very long description with lots of words of the second $x$ variable.
\end{vardesc}
Aenean consequat sapien venenatis,
sollicitudin tellus nec,
sollicitudin lectus.
Curabitur eget pulvinar justo.
\end{document}
解释:
左缩进和变量描述块周围的垂直间距看起来像一个quote
环境,但没有右缩进。因此,该示例定义了环境leftquote
,它复制了的定义quote
,但没有减小右侧的行宽。
符号和等号的垂直对齐是通过表格实现的:
符号左对齐(列类型
l
)并以数学模式设置(>{$}l<{$}
)。等号被放入列规范中
@{${}={}$}
。这样可以避免用户必须为每个变量键入等号,并确保间距一致。等号周围的空组是子公式,TeX 会在其周围添加通常的空格。正确的描述列应该跨越可用空间,因此使用列类型
X
和表环境。tabularx
\tabcol
表格左侧和右侧的额外空格被 抑制@{}
。变量之间有额外的空间。这是由
\addlinespace
包设置的booktabs
。它与表格行的前一个结尾(\tabularnewline
)一起放入一个新宏中\newvar
,该宏结束当前表格行并设置变量描述之间的垂直空间。
答案2
尝试:
\documentclass{article}
\usepackage{amsmath}
\usepackage[active,displaymath,tightpage]{preview}
\setlength\PreviewBorder{5pt}%
\begin{document}
\begin{flalign*}
1. &&
y = & \begin{cases}
1 & \textrm{condition for variable to be unity} \\
0 & \textrm{condition for variable to be zero} \\[+1.5mm]
\end{cases}
& \\
&&
x_1 = &\ \parbox[t]{88mm}{very very very very very very very long description with lots of words of the first $x$ variable}
& \\
&&
x_2 = &\ \parbox[t]{88mm}{very very very very very very very long description with lots of words of the second $x$ variable}
&
\end{flalign*}
\end{document}
调整 parbox 的宽度来适应列的宽度。
答案3
我把这个作为答案,因为我的评论格式搞乱了。我认为你把事情搞得太复杂了,另一个答案也是如此。这有什么问题?
...turpis.
\begin{description}
\item $y=
\begin{cases}
1 & \textrm{condition for variable to be unity} \\
0 & \textrm{condition for variable to be zero}
\end{cases}$
\item[$x_1=$]
very long description with lots of words of the first $x$ variable
\item[$x_2=$]
very long description with lots of words of the second $x$ variable.
\end{description}
\noindent
Aenean...