[comp.text] Nice twocolumn style

wsineel@lso.win.tue.nl (e.vriezekolk) (11/13/89)

I want to use (La)TeX for making a magazine. I want two
columns, but run into problems when using LaTeX's standaard
twocolumn option. There are two problems.

First:
======
		When typesetting articles, I want something like

			article-1  article-1
			article-1  article-1
			article-1  article-1
			article-1  article-1
			article-1  article-1
	
			Title-2
			article-2  article-2
			article-2  article-2
			article-2  article-2
			article-2  article-2
			article-2  article-2

	When using standard LaTeX, the first article comes in the
	first column, and the second article in the second.

Second:
=======
		I want floats to go over column boundaries, like

			texttexttext   texttexttext
			texttexttext   texttexttext
			texttex+-----------+exttext
			texttex|  (float)  |exttext
			texttex+-----------+exttext
			texttexttext   texttexttext
			texttexttext   texttexttext
			texttexttext   texttexttext
			texttexttext   texttexttext
			texttexttext   texttexttext
			+-----------------+texttext
			|    (float)      |texttext
			|                 |texttext
			+-----------------+texttext
			texttexttext   texttexttext
		
		which is impossible with standard LaTeX macros.

I'm not a LaTeX expert, so I can't make the necessary macros
myself. Somewhere must be a TeX expert who has solved my
problems already.


Could someone *please* mail me the macros for making magazine
columns?

Many thanks.

mitsolid@acf5.NYU.EDU (Thanasis Mitsolides) (11/14/89)

/* acf5:comp.text / wsineel@lso.win.tue.nl (e.vriezekolk) /  8:33 am  Nov 13, 1989 */
>I want to use (La)TeX for making a magazine. I want two
>columns, but run into problems when using LaTeX's standaard
>twocolumn option. There are two problems.

I would like to have the unswer too.

Thanasis

jbw@bucsf.bu.edu (Joe Wells) (11/15/89)

In article <702@tuewsd.lso.win.tue.nl> wsineel@lso.win.tue.nl (e.vriezekolk) writes:

   I want to use (La)TeX for making a magazine. I want two
   columns, but run into problems when using LaTeX's standaard
   twocolumn option. There are two problems.

   First:
   ======
		   When typesetting articles, I want something like

			   article-1  article-1
			   article-1  article-1
			   article-1  article-1
			   article-1  article-1
			   article-1  article-1

			   Title-2
			   article-2  article-2
			   article-2  article-2
			   article-2  article-2
			   article-2  article-2
			   article-2  article-2

	   When using standard LaTeX, the first article comes in the
	   first column, and the second article in the second.

None of this is easy with TeX or LaTeX without a certain amount of TeX
programming skill.  You need to modify LaTeX's output routine.  Basically,
you want to call the new output routine after each article, in addition to
at the end of each column.  When the output routine is called at the end
of the first article, the column (or columns) that has already been
collected will need to be resplit into two columns of equal depth.  An
example of how to do this lies somewhere in the depths of the TeXbook.

When you start building the columns of the second article, you'll need to
reduce the target column height to correspond to the amount of space left
on the page.  When the two columns of the second article are finished,
they should be put below the two columns of the first article in a big
box.  Of course, you want to do this in a general manner that will work
for any number of articles on one page.

   Second:
   =======
		   I want floats to go over column boundaries, like

			   texttexttext   texttexttext
			   texttexttext   texttexttext
			   texttex+-----------+exttext
			   texttex|  (float)  |exttext
			   texttex+-----------+exttext
			   texttexttext   texttexttext
			   texttexttext   texttexttext
			   texttexttext   texttexttext
			   texttexttext   texttexttext
			   texttexttext   texttexttext
			   +-----------------+texttext
			   |    (float)      |texttext
			   |                 |texttext
			   +-----------------+texttext
			   texttexttext   texttexttext

		   which is impossible with standard LaTeX macros.

This is more difficult.  It can be done in TeX, but I wouldn't want to
have to do it myself (without a sufficiently large monetary incentive).
This part is easier in some other publishing programs.

   I'm not a LaTeX expert, so I can't make the necessary macros
   myself. Somewhere must be a TeX expert who has solved my
   problems already.

Your first problem has probably been done before.  However, I doubt anyone
has persevered enough to solve your second problem in TeX.  (If someone
has, I would be delighted to hear of it.)

-- 
Joe Wells <jbw@bucsf.bu.edu>
jbw%bucsf.bu.edu@bu-it.bu.edu
...!harvard!bu-cs!bucsf!jbw

dougcc@csv.viccol.edu.au (Douglas Miller) (11/16/89)

A few people have asked for more flexible two-column formatting in LaTeX.
These are the macros that I have been using for a while:

% The twocolumns environment can be used anywhere in a one column document to
% produce two column output.  The twocolumns environment may extend for an
% unlimited number of pages, and start and finish mid-page.  Columns are 
% always balanced.  The code works very hard to avoid two-column ``widows''
% and ``orphans''.  No inserts are supported (haven't worked out where to put
% them yet).

\newbox\partialpage
\newbox\leftcolumn
\newdimen\dimen@
\newdimen\colsize
\newdimen\lastpageshrink
\newdimen\dimend
\newenvironment{twocolumns}{\begingroup
   \pagegoal=2\textheight
   \lastpageshrink=\pageshrink
   \output={\global\setbox\partialpage=\vbox{\unvbox255}}\penalty-10000%
   \def\columnout{\trycolumnout}%
   \output={\columnout}%
   \hsize=\textwidth \advance\hsize-\columnsep \divide\hsize by 2
   \columnwidth=\hsize \linewidth=\hsize
   \global\colsize=\textheight
   \global\advance\colsize by-\ht\partialpage
   \vsize=\colsize
   \global\advance\vsize by\lastpageshrink
   \multiply\vsize by2}%
% \end{twocolumns}
   {\pagegoal=4\textheight
   \output={\balancecolumns\pagesofar}\break
   \endgroup \global\vsize=\textheight \pagegoal=\vsize}

\def\pagesofar{\unvbox\partialpage%
   \wd0=\hsize \wd2=\hsize \hbox to\textwidth{\box0\hfil\box2}}
\def\balancecolumns{\setbox0\vbox{\unvbox255} \dimen@=\ht0
   \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
   \divide\dimen@ by2 \splittopskip=\topskip
   {\vbadness=10000 \loop \global\setbox3=\copy0
     \global\setbox1=\vsplit3 to\dimen@
     \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt\repeat}
   \ifdim\dimen@>\textheight \dimen@=\textheight\fi
   \setbox0=\vbox to \dimen@{\unvbox1} \setbox2=\vbox to \dimen@{\unvbox3}
   \if\ht0>\ht2\setbox2=\vbox to\ht0{\unvbox2}\else
   \if\ht2>\ht0\setbox0=\vbox to\ht2{\unvbox0}\fi\fi}

\def\trycolumnout{%
   \global\def\columnout{\leftcolumnout}
   \global\vsize=\colsize
   \unvbox255\penalty\outputpenalty}
\def\leftcolumnout{%
   \global\def\columnout{\rightcolumnout}
   \global\setbox\leftcolumn=\vbox to\vsize{\unvbox255}}
\def\rightcolumnout{%
   \global\def\columnout{\trycolumnout}
   \setbox0=\box\leftcolumn
   \setbox2=\vbox to \vsize{\unvbox255}
   \setbox\@outputbox=\vbox{\pagesofar}\@outputpage
   \global\colsize=\textheight
   \global\vsize=2\colsize}