# How to make onecolumn/twocolumn parts in a document class?

I have a simple document class adapted from article, but independent (.cls file). The document is twocolumn, but when I add a title with

  \newcommand\maketitle{\begin{titlepage}%
\begin{center}%
{\LARGE \@title \par}%
\end{center}\par
\end{titlepage}%
}
\newenvironment{titlepage}
{%
\@restonecoltrue\onecolumn
\thispagestyle{empty}%
\setcounter{page}\@ne
}%


This makes the entire document onecolumn. How should I set the titlepage environment to be onecolumn without affecting the entire document?

-

The definition of the titlepage environment in article.cls depends on whether compatibility mode is on/off, but both variants include

\if@restonecol\twocolumn \else \newpage \fi


in the code to be executed at the end of the environment. In your version of titlepage, you simply switch to \onecolumn (which makes \@restonecoltrue superfluous) at the start of the environment, so you need to switch back to \twocolumn at the end. I suggest, however, to simply use the original non-compatibility variant of titlepage, as this will make your custom class also work in onecolumn mode.

-
very clear information! I wonder how I missed that critical line :) –  All Apr 16 '12 at 17:11

You can define \maketitle using the optional argument to the command \twocolumn:

\def\maketitle{%
\twocolumn[\vbox to \textheight{\vfil
\begin{center}\LARGE \@title \par\end{center}%
\vfil}]%
\clearpage
}


The command \twocolumn does 3 things:

1. starts a new page if necessary
2. typesets its optional argument in one-column mode
3. the rest of the new page is in two-column mode
-