2

I'd like to call multicols with a parameter being the number of column and allow this parameter to take the value 1, like in this minimal working example :

\documentclass[a4paper,10pt]{report}
\usepackage{multicol,lipsum}

\newcommand{\varcols}[1]{%
\ifnum#1=1\lipsum\else{\begin{multicols}{#1}\lipsum\end{multicols}}\fi
}

\begin{document}
\varcols{3} 
\end{document}

but the problem is that it forces me to write my text (here \lipsum) two times, which is of course not desirable.

I tried another solution, but unfortunately without success :

\newcommand{\varcols}[1]{%
\ifnum#1=1\relax\else{\begin{multicols}{#1}}\fi
\lipsum
\ifnum#1=1\relax\else{\end{multicols}}\fi
}

but this fails : !Extra }, or forgotten \endgroup.

closed as too localized by lockstep, clemens, Stefan Kottwitz Oct 18 '12 at 21:00

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

4

Your \else code is

{\begin{multicols}{#1}}

with spurious brace group around the begin. You just want

\begin{multicols}{#1}

and similarly for the end case,

Not the answer you're looking for? Browse other questions tagged or ask your own question.