Columns

From Wiki
Revision as of 04:35, 10 December 2006 by Rickx (talk | contribs)
Jump to navigation Jump to search

< Visuals | Layout >

There are different possibilities to typeset text in two or more columns:

  • columns : for simple cases of multi column text
  • paragraphs : if you need a table-like structure (translations, questionaires etc.)
  • column sets : the flexible way for varying columns or other complex tasks
  • streams : set different text synchronized side-by-side (e.g. bilingual editions)

Columns

\startcolumns[n=3]
\input knuth
\stopcolumns

You can add all the options of \setupcolumns to \startcommand. You can enforce a new column with \column, but that's a bit broken at the moment (2006-01-14).

Paragraphs

see "Paragraphs in Columns" section in the manual

Column Sets

see Columns manual or column sets source

Streams

see streams source


TODO: We need documentation and samples for Paragraphs, Streams and Column Sets (See: To-Do List)



Floats and other limitations of columns

Columns and one-column floats don't work well together in TeX. It seems that you can't have a float that spans one column automatically put at the top or the bottom and have the columns balanced automatically at the end. Neither ConTeXt nor LaTeX can do it in a automatized way (like with floats that span more than a column). Here you have some tricks to make it work more or less:

Columnsets

With columnsets you can put floats that span one, two or any number of columns and in any position (top, bottom, middle of the text). The price for this is that you have to balance the columns manually at the end (see Columnset manual).

Columnsets have a limitation, however: they are very strongly grid-based, and you can't change the interlinespace within the columnset (e.g., if some paragraphs are typed in a smaller font). You can change the interlinespace if the entire text with a smaller interlinespace fits in one column, like a float or a section title (putting it between \startlinecorrection\stoplinecorrection), but if the text with a smaller interlinespace starts in one column and has to continue in the following one, nothing will work, and the layout will be completely messed.

So, if you want columns and one-column floats and don't have to change the interlinespacing, use Columnsets. If not, you can use Columns with some tricks.

Columns

With Columns you have the columns automatically balanced at the end, but only certain floats are "officially" supported:

  • Floats that span more than a column at the top of the following page
  • Floats that span one column in the middle of the text, accidentally at the top of the following page

Here, the optional argument placefloat[here, top, bottom, etc.] does nothing. When you place a float, if its width is larger than the column width (\textwidth), that float will be automatically put at the top of the following page, spanning the columns needed. If its width is shorter than the column width, the float will be put in the middle of the text, spanning one column. If there is not enough space left in the column, it will float until the top of the following column. You can use this method to put floats at the top of a column, but it's not recommended, because it is tedious and if you change the text before the float, you will probably find it then in the middle of the column.

There is a semi-automatic way to put:

  • Floats that span one column at the top of the left column of a page
  • Any float in a separated page, without text

with the possibility of changing the text and having the float always correctly put, like with "officially" supported floats, using \startpostponing\stoppostponing. Everything that goes into this environment will be put at the beginning of the next page, or in the page indicated in the optional argument (e.g., \startpostponing[34]; see this wiki entry). If we write

\startpostponing[35]
\vbox{\vskip-\baselineskip
\placefigure{caption}{\externalfigure[file][width=\textwidth]}
}
\stoppostponing

the figure will be put at the top of the first column at page 35, or four pages further on, if we put [+4], or on the following page, with no optional argument. The figure has to be enclosed in a box, or the grid will be broken. Putting the figure in a box lowers it a line (why?), so it has to be corrected with the \vskip-\baselineskip.

You can put more than a float in the same column, but they have to be into the same box, or the grid will be broken

\startpostponing
\vbox{\vskip-\baselineskip
\placefigure{caption}{\externalfigure[file][width=\textwidth]}
\placefigure{caption2}{\externalfigure[file2][width=\textwidth]}
}
\stoppostponing

With this method you can put a float in a separated page, without any text

\startpostponing[+5]
\vbox{
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}
}
\page
\stoppostponing

And you can use it to put a float that span more than a column in a page other than the one chosen by the algorithm (without \vbox):

\startpostponing[67]
\placefigure{caption}{\externalfigure[file][width=\makeupwidth]}
\stoppostponing

This has some limitations, too. If you put a float at the top of a column and there is another float that spans more than a column over all, the grid will be broken, so you have to put it in another page, but you can put more than one float of the same type together, as seen above.