1

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}

5
  • 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. Feb 8, 2013 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. Feb 8, 2013 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/… Feb 8, 2013 at 18:09
  • I updated my description. Sorry if I caused confusion.
    – nmn
    Feb 8, 2013 at 19:02
  • l is like mbox and never breaks over a line change ll to lp{5cm} or whatever width you want, Feb 8, 2013 at 21:04

1 Answer 1

1
\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}
4
  • 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?
    – nmn
    Feb 11, 2013 at 14:42
  • There is a longtable/tabulary merge here: tex.stackexchange.com/questions/78075/multi-page-with-tabulary Feb 11, 2013 at 15:41
  • Thanks. Please see my edit above. I tried the code above but the two columns overlap (see picture).
    – nmn
    Feb 11, 2013 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 Feb 11, 2013 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .