# Macro to multicol section content but not section title

\section{Introduction}


I want to write a macro to that makes the above behave the same as:

\usepackage{multicol}
\begin{multicols}{2}[\section{Introduction}]


In praise of code convolution avoidance: The shortest and simplest answer(Most adhering to the KISS philosophy) will be the accepted answer. DON'T use a library if you don't NEED to.

-
Your question is not clear. You want to write \section{Introduction} and have it be the same as \begin{multicols}{2}[\section{Introduction}]? Your directives about what answers are acceptable are ill-advised and frankly, kinda rude. –  TH. Oct 10 '10 at 5:15
You should make it clear whether or not the matching \end{multicols} should also be handled automatically, because taking your request literally, it shouldn't. –  frabjous Oct 10 '10 at 5:30
@TH sorry about that I reworded the question to be more like how I expect answers, honestly I don't know what I was doing up that late last night, anyways. –  GlassGhost Oct 11 '10 at 1:38

Here's the best I could come up with. First, I define \oldsection as the old \section macro, then use it to define a new \section command which first ends the previous multicolumn environment, unless it's the first section, in which case it does nothing, and then starts a new multicolumn environment with a section heading as defined by old section.

I also have to redefine \enddocument to end the final multicolumn.

This is not a very robust or advisable solution, but may work in a pinch.

\usepackage{multicol}
\usepackage{ifthen}
\let\oldsection\section
\renewcommand*{\section}[1]{%
\ifthenelse{\thesection = 0}{}{\end{multicols}}%
\begin{multicols}{2}[\oldsection{#1}]}
\let\oldend\enddocument
\renewcommand*{\enddocument}{\end{multicols}\oldend}


To used as follows:

\documentclass{article}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{ifthen}
\let\oldsection\section
\renewcommand*{\section}[1]{%
\ifthenelse{\thesection = 0}{}{\end{multicols}}%
\begin{multicols}{2}[\oldsection{#1}]}
\let\oldend\enddocument
\renewcommand*{\enddocument}{\end{multicols}\oldend}
\begin{document}
\section{My first section}
\lipsum[1-2]
\section{Another section}
\lipsum[3-4]
\end{document}

-
Worked almost like a charm!! If I could just figure out how to make those foot notes appear pretty and above sections following sections(on the same page); I would say this is worth adding to the multicol package as an option. But that would be another question. –  GlassGhost Oct 11 '10 at 1:45
This seems to break if you add \tableofcontents... also, I changed the ifthen to \ifthenelse{\equal{\@currenvir}{multicols}}{\end{multicols}}{} to specifically check if you're in a multicols before issuing \end, otherwise I got errors on a large document. Still working on the \tableofcontents issue though... –  glallen Sep 19 '12 at 17:28

I don't really understand your question, but this might do what you want:

\newenvironment{xmulticols}[1]{\section{#1} \begin{multicols}{2}}{\end{multicols}}


This would only work if you only ever wanted 2 column layout, but is easily fixable to more columns.

I'd also recommend you also change how the section headings look (maybe make them centered?) to make clear that the section heading "covers" both columns...

-
No, I think he wants to write only \section{blah blah} and have it behave this way. –  frabjous Oct 11 '10 at 0:50
Ah I see. I didn't think of that. I guess because I don't like the idea of having environments begin and end without the \begin and \end markers visible. I'm not sure it's a good idea... –  Seamus Oct 11 '10 at 10:25
Agreed. The whole thing makes me nervous. But I still, I like a challenge. –  frabjous Oct 11 '10 at 15:42