Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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).
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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