[texhax] stretch section title in twocolumn

tom sgouros tomfool at as220.org
Tue May 16 18:23:45 CEST 2006


Paul Tremblay <phthenry at iglou.com> wrote:

> 
> The title in this case would only span across one column. I know it
> seems easy to simply move my \section{The Title} one line above,
> before the multicols environment, but actually in the conversion it
> requires a lot more rules. I would have to write two different set of
> rules, one for a multicolumn document and one for a one-column
> document. In addition, I would have to make sure I started the
> multicols environment each time I have a section break. 
> 
I don't know how you feel about cheating, but I'm lazy, so tend to think
about solutions like the one below, and I wonder if something like this
would work for you.  This requires that you always have a \ssection
command inside your ssectcols environment, but you're generating the
latex, so you can enforce that.  Outside the environment, you can let
\ssection equal \section.

I think somewhere there is a class that allows you to append commands to
existing macros, but I can't think of it.  Probably someone here can.
That would allow a cleaner solution, in that you could modify \section.

 -tom

\documentclass{article}
\usepackage{multicol}
\usepackage{testing} % contains def of \lotsoftext

\newenvironment{ssetcols}{%
  \newcommand{\ssection}[1]{\begin{center}\section{##1}\end{center}%
    \begin{multicols}{2}}}{\end{multicols}}


\begin{document}

# The usual way
\section{First section}
\begin{multicols}{2}
\lotsoftext
\end{multicols}

# Putting the column environment ahead of the section name.
\begin{ssetcols}
\ssection{Second section}
\lotsoftext
\end{ssetcols}

\end{document}


-- 
 ------------------------
 tomfool at as220 dot org
 http://sgouros.com  
 http://whatcheer.net


More information about the texhax mailing list