[texhax] Simple line numbering for tabular environments

James Smith sf at aleph-one.com
Thu Jul 19 11:02:56 CEST 2007


Krishnan that's perfect, thanks muchly.

Reinhard, unfortunately this isn't ``real'' code, even pseudo-code. I
must often mix maths with it and must laboriously typeset most it all by
hand.

> -----Original Message-----
> From: texhax-bounces at tug.org [mailto:texhax-bounces at tug.org] 
> On Behalf Of E. Krishnan
> Sent: 19 July 2007 01:36
> To: James Smith
> Cc: texhax at tug.org
> Subject: Re: [texhax] Simple line numbering for tabular environments
> 
> 
> On Wed, 18 Jul 2007, James Smith wrote:
> 
> > \begin{tabular*}{\linewidth}
> > {l>{$}l<{$}>{$}l<{$}}
> > \hline\\
> > 1&\mathsf{process\_file}(*f:file)\{\\
> > 2&\quad l:string\\
> > 3&\quad l=\mathsf{read\_line}(f)\\  
> >4&\quad\mathsf{while}(l\neq\epsilon))\{\\
> > 5&\quad\quad l=\mathsf{read\_line}(f)\\
> > 6&\quad\}\\
> > 7&\}\\
> > \\
> > \hline
> > \end{tabular*}
> >...........
> > I need the maths environment...... constantly renumbering the lines 
> >when
> > I change the listings becomes tiresome, so can I automate 
> this process. 
> > .......I'd like to keep the tabular* environment if at all possible.
> 
> 
> Please try this:
> 
> 
> \usepackage{array}
> 
> 
> \newcolumntype{M}{>{$}l<{$}}
> 
> \newcounter{rowno}
> \setcounter{rowno}{0} 
> \newcommand{\slno}{\addtocounter{rowno}{1}\therowno}
> \newcolumntype{N}{>{\slno}l}
> 
> 
> \begin{tabular*}{\linewidth}{NMM}
>    \hline
>    \multicolumn{3}{c}{}\\
>    &\mathsf{process\_file}(*f:file)\{\\
>    &\quad l:string\\
>    &\quad l=\mathsf{read\_line}(f)\\
>    &\quad\mathsf{while}(l\neq\epsilon))\{\\
>    &\quad\quad l=\mathsf{read\_line}(f)\\
>    &\quad\}\\
>    &\}\\
>    \multicolumn{3}{c}{}\\
>    \hline
> \end{tabular*}
> 
> 
> 
> -- 
> Krishnan
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
> 
> Automated subscription management: 
> http://tug.org/mailman/listinfo/texhax
> Human mailing list 
> managers: postmaster at tug.org
> 
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.476 / Virus Database: 269.10.9/907 - Release 
> Date: 18/07/2007 15:30
>  
> 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.10.9/907 - Release Date:
18/07/2007 15:30
 



More information about the texhax mailing list