Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a question about breaking lines and pages in table environment. I know, there are some solutions as using longtable package, however, it is quite complicated and I don't know how to work with it....I'm writing the list of symbols and abbreviations. I'm using the standard look with no lines at all, only two columns left side symbol, right side explanation. I have two problems.

  1. In case of a long explanation I need to put handy \\ at the end of a line to break it, but it's not the same length for all rows.
  2. Sometimes I need to put one table in two pages and I don't know how to break it automatically.

Is there any simple solution of these problems?

\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}

To the point 1. In every item I need to put handy \\ & (after distribution) to cut it because it is long and the rows are not the same length...I'd like to ask how to do it automatically the breaking at the end of lines.

share|improve this question
1  
The package longtable is not complicated at all if you spend five minutes trying to understand it. However, it is not very robust in interaction with other packages. See this Q&A for a worked example, as well as some problems. –  Fred Jul 1 '12 at 17:03
    
It's pretty complicated, however, I'm using lots of packages, so it would not be probably work either... –  Jane Jul 1 '12 at 17:15
    
Your fist comment is not clear at all. It is always clearer if you make an example. Perhaps you just need to use a p column rather than a c column to allow automatic line breaking within the cell? As for point 2, that's what longtable does: the table should just break at the end of the page automatically. –  David Carlisle Jul 1 '12 at 20:06
    
A tip: you can highlight code by selecting it and pressing Ctrl + K, or clicking the {} button on the toolbar above the text field. This adds backticks (`) around inline text, and indents blocks with four spaces. –  Torbjørn T. Jul 1 '12 at 20:44

2 Answers 2

up vote 4 down vote accepted

enter image description here

You are mis-using the l column which is designed for single-line entries. In the tabular you should use a p column to allow line breaking to the specified width. In its simplest use longtable markup is identical to tabular just change the environment name and it allows page breaking. The following document shows you a tabular using p and the equivalent 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}
share|improve this answer

Try using the tabu-package with longtabu. The simplest longtabu is:

\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}
share|improve this answer
    
It does not keep the same length of the lines automatically, I see. In other words, it does not solve the problem one... –  Jane Jul 1 '12 at 17:18
    
@Jane Do you mean justified text by “same length of the lines”? If so try X[2j] instead of X[2l] and leave the \newlines out. –  cgnieder Jul 1 '12 at 17:48
    
@Jane I have misunderstood your question. I was of the impression you wanted manually to break line. Please, describe what you actually want to achieve. Just remove the \newline-commands, and the lines break automatically. –  Sveinung Jul 1 '12 at 22:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.