3

I'm not entirely sure what I'm doing wrong here, I'm using a \kill'd line to mark the tabs first, but it's still giving me an undefined tab position error.

The error is reported for line 0 so I'm not sure which of these is causing it.

\begin{framed}
\begin{tabbing}
tabs \= tabs \= tabs \kill
Give $a$ the value 2.
Give \emph{prime} the value $T$.
While $a \leq \sqrt{n}$ and \emph{prime} $= T$
\> if $a$ divides $n$
\> \> then give \emph{prime} the value $F$
\> \> else increase the value of $a$ by 1.
\end{tabbing}
\end{framed}

\begin{framed}
\begin{tabbing}
tabs \= tabs \= tabs \kill
Give $a$ the value $m$, and $b$ the value $n$.
Find remainder $r$ of $a$ divided by $b$.
While $r \neq 0$:
\> assign $a$ the value $b$
\> assign $b$ the value $r$
\> recompute the remainder when
\> $a$ is divided by $b$.
Give $d$ the value of $b$.
\end{tabbing}
\end{framed}

Can anybody tell me what I'm doing wrong?

1 Answer 1

4

Since you're not inserting any line breaks, more than 3 "tab skips" occurs in the last line of the first tabbing.

The tabbing environment requires line breaks \\ which allows for adequate tabbing \>:

enter image description here

\documentclass{article}
\begin{document}
Some text before \verb|tabbing|.
\begin{tabbing}
tabs \= tabs \= tabs \\ \kill
Give $a$ the value 2. \\
Give \emph{prime} the value $T$. \\
While $a \leq \sqrt{n}$ and \emph{prime} $= T$ \\
\> if $a$ divides $n$ \\
\> \> then give \emph{prime} the value $F$ \\
\> \> else increase the value of $a$ by 1.
\end{tabbing}

\bigskip

Some text before \verb|tabbing|.
\begin{tabbing}
tabs \= tabs \= tabs \\ \kill
Give $a$ the value $m$, and $b$ the value $n$. \\
Find remainder $r$ of $a$ divided by $b$. \\
While $r \neq 0$: \\
\> assign $a$ the value $b$ \\
\> assign $b$ the value $r$ \\
\> recompute the remainder when \\
\> $a$ is divided by $b$. \\
Give $d$ the value of $b$.
\end{tabbing}
\end{document}

More specifically, tabbing has/requires the syntax:

  • \= defines a tab position;
  • \> defines a tab skip;
  • \\ inserts a line break (and "resets" the tab positions);
  • \kill removes a line inside tabbing (typically used in the "tab position/first" line).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .