表环境

表环境

我有一个关于在表格环境中换行和换页的问题。我知道,有一些解决方案,比如使用longtable包,但是,它相当复杂,我不知道如何使用它……我正在写符号和缩写的列表。我使用标准外观,根本没有线条,只有两列左侧符号,右侧说明。我有两个问题。

  1. 如果解释很长,我需要\\在行末放置一个方便的分隔符,但所有行的长度并不相同。
  2. 有时我需要将一个表格放在两页中​​,但我不知道如何自动将其拆分。

这些问题有没有什么简单的解决办法?

\begin{tabular}{ll}
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution\\ & with mean $\mu$ and variance ${\sigma}^{2}$\\
\end{tabular}

关于要点 1. 在每个项目中,我需要将\\ &其放在手边(分配后)以便剪切,因为它很长并且行的长度不一样......我想问如何在行末自动断开。

答案1

在此处输入图片描述

您错误地使用了l为单行条目设计的列。在表格中,您应该使用列p来允许按指定宽度换行。在最简单的用法中,longtable标记与仅更改环境名称相同tabular,并且它允许分页。以下文档向您展示了tabular 使用p和等效的longtable

\documentclass{article}

\setlength\textheight{15\baselineskip}

\usepackage{longtable}

\begin{document}

\begin{tabular}{ll}
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution\\ & with mean $\mu$ and variance ${\sigma}^{2}$\\
\end{tabular}


\begin{tabular}{lp{6cm}}
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$
\end{tabular}


\begin{longtable}{lp{6cm}}
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
$X\sim\mathsf{N}(\mu,\,{\sigma}^{2})$& the random variable $X$
has normal (Gaussian) distribution with mean $\mu$ and variance ${\sigma}^{2}$\\
\end{longtable}
\end{document}

答案2

尝试使用tabu-package longtabu。最简单的方法longtabu是:

\documentclass{article}
\usepackage{booktabs,longtable,tabu}

\begin{document}
\begin{longtabu} to \linewidth {@{}X[l]X[l]X[2l]@{}} \toprule

Item    &   Qualifier   &   Description \\
\midrule

Item 1  &   Punch drunk &   A very long description \newline
                            that need som linebreaks to look \newline
                            nice and fit \

Item 2  &   Just drunk  &   Also have very long description \newline 
                            that need som linebreaks to look \newline 
                            nice and fit \\ \bottomrule
\end{longtabu}

\end{document}

相关内容