one-column multicol environment

This solution is inspired by Werner's, but it supports the optional argument to \begin{multicols} and, more importantly, doesn't collect the whole contents in a single swoop, which is best to avoid, if possible. It also doesn't require changing the environment's name.

\documentclass{article}
\usepackage{multicol,lipsum,xparse}

\let\multicolmulticols\multicols
\let\endmulticolmulticols\endmulticols

\RenewDocumentEnvironment{multicols}{mO{}}
 {%
  \ifnum#1=1
    #2%
  \else % More than 1 column
    \multicolmulticols{#1}[#2]
  \fi
 }
 {%
  \ifnum#1=1
  \else % More than 1 column
    \endmulticolmulticols
  \fi
 }

\begin{document}

\begin{multicols}{2}[\section{Title in single column}]
\lipsum[1-2]
\end{multicols}

\begin{multicols}{1}
\lipsum[1-2]
\end{multicols}

\end{document}

enter image description here


You can use an alternative environment which conditions on whether you're managing a single or multiple columns:

enter image description here

\documentclass{article}
\usepackage{multicol,lipsum,environ}

\NewEnviron{auxmulticols}[1]{%
  \ifnum#1<2\relax% Fewer than 2 columns
    %\vspace{-\baselineskip}% Possible vertical correction
    \BODY
  \else% More than 1 column
    \begin{multicols}{#1}
      \BODY
    \end{multicols}%
  \fi
}

\begin{document}

\begin{auxmulticols}{2}
\lipsum[1-2]
\end{auxmulticols}

\begin{auxmulticols}{1}
\lipsum[1-2]
\end{auxmulticols}

\end{document}

multicol expects to capture the end of the environment in order to gauge where the multicols text ends. Wrapping it inside a new environment that captures the entire content in (say) \BODY (as is done using environ) allows you to condition on certain arguments before handling the output.

Tags:

Multicol