# Trick Supertabular into Multicols in new command

I'm using supertabular in multicols enviroment using this trick

\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother


I'd like to put that code into \newcommand - I've tried this:

\newcommand{\TrickSupertabularIntoMulticols}{
\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother
}


but when i use my \newcommand it doesn't work - table is in only one column. What is the right way to define this command?

EDIT: examples

this works fine but i generate multiple multicols in the document so I want to put that trick code into single line comand

\documentclass{article}
\usepackage{supertabular,multicol}

\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<100
\protected@edef\tablebody{\tablebody
\textbf{\number\n.}& shortText
\tabularnewline
}
\repeat
\makeatother

\begin{document}
\begin{multicols*}{2}
\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother

\begin{supertabular}{|l|l|}
\tablebody
\end{supertabular}
\end{multicols*}
\end{document}


and this doesn't work

\documentclass{article}
\usepackage{supertabular,multicol}

\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<100
\protected@edef\tablebody{\tablebody
\textbf{\number\n.}& shortText
\tabularnewline
}
\repeat
\makeatother

\newcommand{\TrickSupertabularIntoMulticols}{
\let\mcnewpage=\newpage
\makeatletter
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}
\makeatother
}

\begin{document}
\begin{multicols*}{2}
\TrickSupertabularIntoMulticols
\begin{supertabular}{|l|l|}
\tablebody
\end{supertabular}
\end{multicols*}
\end{document}

-
\makeatletter and \makeatother should go as the first and last line respectively (outside the definition of \TrickSupertabularIntoMulticols). Also \let\mcnewpage\newpage should go outside, but it's not as relevant. –  egreg Mar 28 '13 at 16:21
That didn't help –  Abdul Mar 28 '13 at 16:43
A minimal working example (MWE) (also non working, actually) is needed. –  egreg Mar 28 '13 at 16:53

This works.

\documentclass{article}
\usepackage{supertabular,multicol}

\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<100
\protected@edef\tablebody{\tablebody
\textbf{\number\n.}& shortText
\tabularnewline
}
\repeat

\makeatletter
\let\mcnewpage=\newpage
\newcommand{\TrickSupertabularIntoMulticols}{%
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}%
}
\makeatother

\begin{document}
\begin{multicols*}{2}
\TrickSupertabularIntoMulticols
\begin{supertabular}{|l|l|}
\tablebody
\end{supertabular}
\end{multicols*}
\end{document}


You have to put \makeatother and \makeatletter outside the macro definition.

-
Oh it really works, i've tried that as you suggested in comment but i must have made some mistake –  Abdul Mar 28 '13 at 17:44