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.

For a technical documentation (two columns: function name left, description right) I need a way for automatic line and page breaks in a table environment in case the descriptions get a bit longer.

I am currently using tabulary which I thought worked fine but breaks when the table is longer than one page. I wanted to try out the longtable package but I can't get it to work:

misplaced alignment tab character &

And after a \\ for the next row

there is no line here to end.

I couldn't find any information on what seems to be the standard way to handle this. There seem to be a bunch of packages (tabularx, tabulary, longtable, ...) with more or less overlapping functionalities.

edit:

This is an example for the longtable use. Notice how the line expands over the end of the page (It didnt work in my original document, perhaps there are some conflicting packages. nevermind).

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tabulary}
\usepackage{longtable}
\begin{document}
\begin{longtable}{ll}
-foobar & preeeeeeeeeeeeeeeeeeeeety long string here whic doesnt automatically break when it reaches the end of the current line.
\end{longtable}
\end{document}

If you replace the \begin{longtable} with \begin{tabulary}{\textwidth}{l J} the break at the end of the line works, but now longer documents are not possible anymore since page breaks are not handled.

A list description could work I suppose only that I would like for the text to not continue directly below the description text but is indented to the right so that there is space below the description text (like in a table).

Edit2:

I tried the code posted here with the following result:

Link to Image

I did the table itself with \begin{ltabulary}{LJ}

share|improve this question
    
tabularx tabulary and longtable also share an author:-) You can use a multi-page tabulary here tex.stackexchange.com/questions/78075/multi-page-with-tabulary Not sure what other help I can offer given so little information. –  David Carlisle Feb 8 '13 at 17:55
    
Note that it can not be in a table environment if it needs to be multi-page. floats are boxes and never break. –  David Carlisle Feb 8 '13 at 17:59
    
A two column function description list sounds more like a list than a table (which is much easier to handle over page breaks) tex.stackexchange.com/questions/89995/… –  David Carlisle Feb 8 '13 at 18:09
    
I updated my description. Sorry if I caused confusion. –  user25682 Feb 8 '13 at 19:02
    
l is like mbox and never breaks over a line change ll to lp{5cm} or whatever width you want, –  David Carlisle Feb 8 '13 at 21:04
add comment

1 Answer

up vote 1 down vote accepted
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tabulary}
\usepackage{longtable}
\begin{document}
\begin{longtable}{lp{5cm}}
-foobar & preeeeeeeeeeeeeeeeeeeeety long string here whic doesnt automatically break when it reaches the end of the current line.
\end{longtable}

\end{document}
share|improve this answer
    
Thanks. This works for now. But I still have to adjust the column width manually. Is there no way to do this automatically, like the tabulary package handles this? –  user25682 Feb 11 '13 at 14:42
    
There is a longtable/tabulary merge here: tex.stackexchange.com/questions/78075/multi-page-with-tabulary –  David Carlisle Feb 11 '13 at 15:41
    
Thanks. Please see my edit above. I tried the code above but the two columns overlap (see picture). –  user25682 Feb 11 '13 at 19:58
    
you probably want to use l not L for the first column, or set the parameters to stop ty columns being to small. The columns are not overlapping it's just that the first column is very narrow and -foobar doesn't hyphenate so it will stick out –  David Carlisle Feb 11 '13 at 20:28
add comment

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.