The ntabbing environment^{∗}

Gideon Stupp

                  stupp@math.tau.ac.il

April 9, 2000

Abstract

The ntabbing environment is an extension of the tabbing environment that supports automatic line numbering. The lines can be referenced using the standard \label and \ref mechanism.

1 Intorduction

Figure 1 shows an ntabbing environment example and its corresponding latex output. Every line inside the ntabbing environment which is labeled is automatically numbered. The lines can be referenced from within the environment or from the outside. If a line just needs to be numbered, \label{} can be used. Line numbers can be reset back to one at any point using the \reset command (line numbering continues across ntabbing environments)

2 User Interface

\begin{ntabbing}

\end{ntabbing} The text that needs to be numbered should start with \begin{ntabbing} and end with \end{ntabbing}. The ntabbing environment is an extension of the tabbing environment and all the tabbing commands are supported.

\label{} The \label{} command automatically numbers the line with the current sequence number. It can appear at any point in a line up to the \\.

\label{xxx} Like \label{} but the line can be referenced using \ref{xxx}.

\reset Resets line numbering. Line numbers can be reset several times in the environment. Notice that line numbers are not automatically reset at the beginning of every ntabbing block.

∗The latest version of this file and the associated latex style can be found at ftp://ftp.math.tau.ac.il/pub/stupp/latex.

 Recursion example (Function $f$, Line~\ref{rec}).
\begin{ntabbing}
123\=123\=\kill
int $f$(int $i$)\\
\>if ($i<2$) return($i$); \label{}\\
\>return $i$*$f$($i-1$); // recurse\label{rec}\\
\\
\reset
 int main()\\\
 \>for $i$:=1 to 10\label{}\\
 \>\>$s:=s+f(i)$;\label{}\\
 \>return(s);\label{}\\
\end{ntabbing}

Recursion example (Function f, Line 2).

int f(int i)

1:  if (i < 2) return(i);
2:  return i*f(i − 1); // recurse

int main()

1:  for i:=1 to 10
2:  s := s + f(i);
3:  return(s);

Figure 1: Simple ntabbing example.