Changes

Jump to navigation Jump to search
4,530 bytes added ,  10:49, 18 January 2020
fix links to manuals and a few typos
< [[Visuals]] | [[Layout]] >
 
(This page is a mess. The variety of column modes is just confusing. Have a look at the [[manual:columnsets.pdf|Columnsets manual]] and the [[manual:pagecolumns.pdf|Page Columns manual]].)
 
= Overview =
There are different possibilities to typeset text in two or more columns:
* paragraphs : if you need a table-like structure (translations, questionaires etc.)
* column sets : the flexible way for varying columns or other complex tasks
* page columns : new column sets implementation
* streams : set different text synchronized side-by-side (e.g. bilingual editions)
Columns and columnset columnsets are two different mechanism two mechanisms to produce a documentwith text and two or more columnsof text. * The <code>columns </code> mechanism is the older one with limited control about the placement of figures but allows you to mix one column and multicolumns text on a page. * Columnsets <code>columnsets</code> are a new version of the column mechanism meant for magazine-like layouts with more control about the placement of figures and other features like spanned columns etc. (look at the [[Columns#Column_Sets|manual ]] for more) . Additionally, there’s still the old columns and is better suited for magazine-like layoutscolumnsets code available as a module.
=Columns=
<texcodecontext source=yes>\startcolumnssetuppapersize[n=3A5]\input knuth\stopcolumns</texcode>
<context>
\setupbodyfont[rm, 9pt]
\startcolumns[n=3]
\input knuth
</context>
You can add all the options of <{{cmd>|setupcolumns</cmd> }} to <cmd>startcolumn</{{cmd>|startcolumns}}. For example, simple ruled columns are easy:
<texcodecontext source=yes>\setupbodyfontsetuppapersize[9ptA5]\startcolumns[n=2,rule=on]\input knuth\stopcolumns</texcode>
<context>
\setupbodyfont[9pt]
\startcolumns[n=2,rule=on]
\input knuth
</context>
Normally, columns are automatically balanced with the text distributed over the number or of requested columns. You can provoke a column switch using <{{cmd>|column}}. </cmdcontext source=yes>.\setuppapersize[A5]
<texcode>
\startcolumns[n=2]
\input knuthward
\column
\input tufteweisman
\stopcolumns
</texcodecontextColumn balancing fails in "lines" mode (e.g. for poetry).  Influencing the color of the separator rule is somewhat tricky: <context source=yes>\setuppapersize[A5]\setupcolors[textcolor=blue]
<context >\setupbodyfontcolor[9ptred]% rule color, but might influence also the color of other elements\startcolumns[n=23,rule=on]
\input knuth
\column
\input tufte
\stopcolumns
</context>
 
Column balancing fails in "lines" mode (e.g. for poetry).
=Paragraphs=
For example:
<context source="yes">
\enableregimesetuppapersize[utfA5
\defineparagraphs[TwoThird][n=2]
 
% The width of the second paragraph is automatically calculated if unspecified.
\setupparagraphs[TwoThird][1][width=.66\textwidth]
% The width of the second paragraph is automatically calculated if unspecified.
\startTwoThird
\quotation{...{\it why is there something rather than nothing?}
and not otherwise.}
\nextTwoThird
G. W. Leibniz, {\emit\fr Principes de la nature et de la grâce fondés en raison,} 1714.
\stopTwoThird
</context>
See "Paragraphs in Columns" section in the [http://pmrb.free.fr/contextref.pdf ConTeXt reference manual][[manual:cont-enpcontextref.pdf|manual]]for further details. =(Simple)Columns in a narrow frame=To put multiple columns in a frame, this works: <context source="yes">\setuppapersize[A5] \framed[width=0.9\hsize,location=middle]\bgroup \startnarrower[2*middle] \setlocalhsize \hsize\localhsize \startsimplecolumns \input tufte \stopsimplecolumns \stopnarrower\egroup</context> Another possibility is to use [[TextBackground|textbackground]] around the text. <context source="yes">\setuppapersize[A5] \setupcolors[state=start]\definetextbackground [book] [state=start, topoffset=.5ex, location=paragraph, leftoffset=1ex,bottomoffset=1ex] \starttextbackground[book] Tufte again \startcolumns[n=2] \input tufte \stopcolumns\stoptextbackground</context>
=Column Sets=
This method offers more possibilities than simple columns,
in particular in placing floats such as figures and in creating columnspans.
See [[manual:columnscolumnsets.pdf|Columns Columnsets manual]] or [[source:page-set.texmkiv|column sets source]] for many examples.
If you don't need much more than the "normal" columns, but e.g. "lines" mode, try this:
<context source="yes">
\setuppapersize[A5]
 
\definecolumnset[TwoColumns][n=2]
</context>
For more details (layout grid features, spreads, different column widths etc.) please refer to the [[manual:columnscolumnsets.pdf|manual]]!
==Vertical lines between columnsets (rules)==
Sometimes it is required to have a vertical line between the columns of your columnset. This code draws MetaPost lines in the right place (note that it uses textbackground)<context source=yes>\setuppapersize[A5]
<texcode>\startuseMPgraphic{verticallineverticalrule} for i=1 upto NOfTextColumns-1 if CurrentColumn < NOfColumns : draw (rightboundary TextColumns[i]) OverlayBox shifted (2.5mm4mm,0) shifted -\MPxy\textanchor ; endfor ; setbounds currentpicture to OverlayBox enlarged 2.5mm; fi
\stopuseMPgraphic
\defineoverlay [verticallineverticalrule] [\useMPgraphic{verticallineverticalrule}]\setupbackgrounds[text][background=verticalline] \definecolumnset[exampleTwoColumns][n=32,distance=5mm]\setupcolumnset[example][1,2][balancebackground=yesverticalrule]
\starttext
\chapter{Chapter One}\startcolumnset[exampleTwoColumns] \starttextbackground[text] startlines % enforce line breaksStarlight, star bright,first star I see tonight;\stoplines \dorecurse {10}{column \input knuth} startlinesI wish I may, I wish I mighthave the wish I wish tonight.\stoptextbackgroundstoplines 
\stopcolumnset
\stoptext
</texcodecontext=Page Columns= Page columns are a new implementation of columnsets, intended to replace the old mechanism.[[manual:pagecolumns.pdf|Page Columns manual]] From the [[source:page-cst.mkiv|source]]: Columnsets are kind of special. They are mostly meant for special products withmagazine like properties. They are normally not mixed with single column layoutsand not all features of ConTeXt might cooperate well with a mechanism likethis. We use the name page grid because (as with other reimplementations ofMkII features in MkIV, we need another namespace in order to migrate stepwise.This implementation is not neccessarily better than the previous one but it mightbe easier to extend it. It should be a bit more efficient.
=Streams=
This is useful for, e.g., typesetting bilingual books: have the original on the even pages, the translation on the odd pages, and synchronize at certain points.
Hans later re-implemented that mechanism in the core. For details see [[source:mpage-streamsstr.texmkiv|streams module the source]].
The module provides a rather low-lever level interface. Hans suggested some handy shortcuts:
<texcode>
\usemodule[streams]
\def\Translation{\SwitchToRight}
\StartCouple
\Original\en
Are you sleeping, brother John?
\Translation\de
Bruder Jakob, schläfst du noch?
\StopCouple
</texcode>
So you put the part of your document where synchronization should take place between <cmd>StartCouple</cmd> and <cmd>StopCouple</cmd>. After that , <cmd>Original</cmd> and <cmd>Translation</cmd> switches between even and odd pages.
Beware, streams don't don’t work in columns and not very good in columnsets. ==Examples of MkIV streams== (copied from the source) <texcode>\enabletrackers[streams.flushing] \setuplayout[grid=yes] \showgrid \starttext \input tufte \startoutputstream[nl] Wat doen we hier? \enableoutputstream[en] Are you sleeping, brother John?\footnote{xxx} \dorecurse{4}{x \footnote{note \recurselevel}\input tufte \par \pushoutputstream} \enableoutputstream[de] Bruder Jakob, schläfst du noch?\footnote{yyy} \dorecurse{4}{x \footnote{note \recurselevel}\input ward \par \pushoutputstream} \disableoutputstream \stopoutputstream Vader Jacob, slaap je nog?\footnote{zzz} \input tufte \synchronizestreams[en,de,nl] \page \flushoutputstream[en] \input knuth\page \flushoutputstream[de] \input knuth\page \flushoutputstream[nl] \input knuth \stoptext</texcode> Posting by Wolfgang to the mailing list (2016-11-27): <texcode>\starttext \startoutputstream[one] \setupalign[flushleft] \dorecurse{3}{Line \recurselevel\par}\pushoutputstream \blank \dorecurse{6}{Line \recurselevel\par}\pushoutputstream \blank \dorecurse{4}{Line \recurselevel\par}\pushoutputstream\stopoutputstream \startoutputstream[two] \setupalign[flushright] \dorecurse{5}{Line \recurselevel\par}\pushoutputstream \blank \dorecurse{2}{Line \recurselevel\par}\pushoutputstream \blank \dorecurse{7}{Line \recurselevel\par}\pushoutputstream\stopoutputstream \synchronizestreams[one,two] \startoverlay {\outputstreambox[one]} {\raise2\strutdp\outputstreambox[two]}\stopoverlay \stoptext</texcode> (Wolfgang continued:) The mechanism to create pages/columns for the stream content ismissing.You can save text and flush it afterwards but there is no command whichplaces the content side by side (or in columns). Below is a simple examplebut I had to write the splitter myself. <texcode>\starttext \startoutputstream[one] \startcolor[red] \dorecurse{10}{\input knuth\par} \stopcolor\stopoutputstream \startoutputstream[two] \startcolor[green] \dorecurse{10}{\input zapf\par} \stopcolor\stopoutputstream \synchronizestreams[one,two] \setbox\scratchboxone\outputstreambox[one]\setbox\scratchboxtwo\outputstreambox[two] \doloop {\ifvoid\scratchboxone \exitloop \else \setbox\scratchboxfour\vsplit\scratchboxone to \textheight \vbox to \vsize{\box\scratchboxfour\vss}% \setbox\scratchboxfive\vsplit\scratchboxtwo to \textheight \vbox to \vsize{\box\scratchboxfive\vss}% \fi} \stoptext</texcode>
{{todo|We need documentation and samples for Paragraphs, Streams and Column Sets}}
=Floats and other limitations of columns=
Columns and one-column floats don't 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 [[manual:columnscolumnsets.pdf|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 <code>\startlinecorrection\stoplinecorrection</code>), 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.
Changing the font weight or shape inbetween <cmd>startcolumnset</cmd> and <cmd>stopcolumnset</cmd> may cause some columns to be shifted vertically. Then you must use <cmd>restoreinterlinespace</cmd> after the font switch (<cmd>bf</cmd>, <cmd>ss</cmd>) to correct the interline spacing. See [http://thread.gmane.org/gmane.comp.tex.context/20932].
So, if you want columns and one-column floats and don't don’t have to change the interlinespacing, use Columnsets. If not, you can use Columns with some tricks.
==Columns and Floats ==
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.
 
{{Columns navbox}}

Navigation menu