1

Is there an easy / elementary way to get a "tabbing" here?

enter image description here

Note, that the number of rows and columns is basically variable or depends on the loop.

\documentclass[a4paper]{article}
\usepackage{tikz}

\newcounter{rowno}
\setcounter{rowno}{-1}
%\stepcounter{rowno}
%\therowww
\begin{document}
\def\Rows{7}
\foreach \n in {1,...,\Rows}{%%
%\noindent\n,~
\foreach \col in {1,...,\Rows}{% 
\pgfmathsetmacro\filled{\col<=\n ? 1 : 0} 
\pgfmathsetmacro\first{\col==\n ? 1 : 0} 
\noindent\ifnum\filled=1 \stepcounter{rowno}%
         \ifnum\first=1 \col f, \therowno%
            \else  \col,\therowno\fi%
           ~~~ \else  x\fi
}\\%
}%%
\end{document}
3

Yes. The tabto package can help. Here, \tabstart defines the left margin of the table, and the length \tabinc gives the column spacing increment.

\documentclass[a4paper]{article}
\usepackage{tikz,tabto}
\newlength\currtab
\newlength\tabinc
\setlength\tabinc{30pt}
\def\tabstart{0pt}
\newcounter{rowno}
\setcounter{rowno}{-1}
%\stepcounter{rowno}
%\therowww
\begin{document}
\def\Rows{7}
\foreach \n in {1,...,\Rows}{%%
\noindent
\setlength{\currtab}{\tabstart}%
\tabto{\currtab}%
%\noindent\n,~
\foreach \col in {1,...,\Rows}{% 
\pgfmathsetmacro\filled{\col<=\n ? 1 : 0}%
\pgfmathsetmacro\first{\col==\n ? 1 : 0}%
\noindent\ifnum\filled=1 \stepcounter{rowno}%
         \ifnum\first=1 \col f, \therowno%
            \else  \col,\therowno\fi%
            \else  x\fi
  \global\addtolength{\currtab}{\tabinc}%
  \tabto{\currtab}%
}%
}%%
\end{document}

enter image description here

1
  • 1
    Ah, helps me good!
    – cis
    Sep 17 '20 at 16:43
1

enter image description here

\documentclass[a4paper]{article}



\begin{document}
\def\Rows{7 }
\newcount\rrr \rrr=1
\newcount\ccc \ccc=1
\newcount\ttt \ttt=0

\loop
{%
\loop
\makebox[3em][l]{%
\ifnum\rrr<\ccc
x%
\else
\the\ccc
\ifnum\rrr=\ccc f\fi
,\the\ttt
\global\advance\ttt1
\fi
}
\ifnum\ccc<\Rows
\advance\ccc1
\repeat
}
\par
\ifnum\rrr<\Rows
\advance\rrr1
\repeat

\end{document}
2
1

enter image description here

\documentclass[margin=5mm, varwidth]{standalone}
\usepackage{tikz}
\begin{document}

\section{Normal Tabbing}
\begin{tabbing}
Left \= Middle \= Right \kill
1 \> 2 \> 3 \\
\end{tabbing}

\section{Foreach Tabbing}
\newcommand\tabrow[1]{%
\setlength{\topsep}{2pt}%
\setlength{\partopsep}{0pt}%
\begin{tabbing}
Left \= Middle \= Right \kill% tabhead
%1 \> 2 \> 3    %\\
#1    %\\
\end{tabbing}}
%Test: \tabrow{1 \> 2 \> 3}

\foreach \m in {0,1,...,7}{
\ifnum\m=0 \tabrow{$m$ \> $m^2$ \> $m+1$}% 
\else%
\pgfmathsetmacro\mI{\m*\m}
\pgfmathsetmacro\mII{\m+1}
\tabrow{\m \> \mI \> \mII}
\fi}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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