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
\advance\n by1
\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
\advance\n by1
\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}
\makeatletterand\makeatothershould go as the first and last line respectively (outside the definition of\TrickSupertabularIntoMulticols). Also\let\mcnewpage\newpageshould go outside, but it's not as relevant. – egreg Mar 28 '13 at 16:21supertabularthat starts in the middle of page 18, resulting file stops at page 17. Any idea about this? – Chamila Wijayarathna Jul 09 '18 at 12:48