[Tex/LaTex] How to make onecolumn/twocolumn parts in a document class

documentclass-writingtitlestwo-column

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?

Best Answer

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.