Generalwhiledo inside tabular?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

whiledo inside tabular?

Post by karlisrepsons »

Colleagues,
may I ask one more question, as I'm stuck with this: how to use \whiledo inside tabular environment?

Here is a function, which somehow needs to output '&' to the tabular out of whiledo loop:

Code: Select all

\newcommand{\VAanalyse}[2]{
   \subsubsection{\fontspec{#1}#1}
   \begin{verse}
      \begin{tabular}{rl}
         variant & demonstration \\
         \hline \\
         \newcounter{ctr}
         \setcounter{ctr}{1}
         \whiledo{\value{ctr}<#2 \OR \value{ctr}=#2}
         {
            \arabic{ctr} &
               {
                  \fontspec[Variant=\arabic{ctr}]{#1}
                  \testtext
               } \\
            \stepcounter{ctr}
         }
      \end{tabular}
   \end{verse}
}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

whiledo inside tabular?

Post by phi »

You cannot use the unexpandable commands from the ifthen package here; the loop must be fully expandable. Here is an example using the etextools package:

Code: Select all

\documentclass{minimal}
\usepackage{etextools}
\newcommand*{\printline}{}
\def\printline[#1]#2#3{#3\number\numexpr#1+1&a\\}
\begin{document}
\begin{tabular}{rl}
  \naturalloop[\printline]{10}{}
\end{tabular}
\end{document}
karlisrepsons
Posts: 50
Joined: Sat May 23, 2009 10:13 pm

Re: whiledo inside tabular?

Post by karlisrepsons »

Waa, but how can I understand that? So its not possible to define only a new command and use counters as usual in LaTeX? Only with TeX command? (well, I hope you'll come back to take a look)
Post Reply