🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #12184

Re: texinfo tables with borders

#12184
From: Joseph H Allen
Date: Tue, 11 Jul 2000 00:00
256 lines
9621 bytes
Over the weekend I've finally learned TeX for real.  It's actually a breeze
(for programmers, anyway) with good material: I recommend these two books: A
Beginner's Book of TeX by Raymond Seroul and Silvio Levy (ISBN
0-387-97562-4), and The Advanced TeXbook by David Salomon (ISBN
0-387-94556-3).  These are vastly better than The TeXbook (which I find to
be too annoying and difficult to put up with).

Anyway, I've extracted enough information from these to create the document,
including ugly MS-Word tables with too many borders.  I'm going to make a
mini parser (as a separate C program) which will translate a very restricted
(nearly control-sequence free) input format into TeX.

Here is my example document (run it a few times for ToC to be created
properly- you need a fred.eps file as an example figure).

%%% Joe's Simple Format %%%

% Load .EPS file inclusion macros
\input epsf

%%% Misc. macros

% This macro causes the the text which follows to be on an odd numbered page.
\def\forceodd{\ifodd\pageno\else\null\vfill\eject\fi}

\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax}
\def\paramone#1#2{#1}
\def\firstparam#1{\expandafter\paramone #1}
\def\paramtwo#1#2{#2}
\def\secondparam#1{\expandafter\paramtwo #1}

% Right justified paragraph mode
\def\raggedleft{\leftskip=0pt plus \hsize
\parfillskip=0pt\spaceskip=.3333em\xspaceskip=.5em}

%%% Fonts
\font\textfont=cmr12
\font\chapterfont=cmbx17 scaled\magstep2
\font\tocchapterfont=cmbx17
\font\sectionfont=cmbx12
\font\ssectionfont=cmr12

%%% Load and then create cross reference file.
\newread\aux
\immediate\openin\aux=\jobname.aux
\ifeof\aux \message{! No file \jobname.aux;}
\else \input \jobname.aux \immediate\closein\aux \fi
\newwrite\aux
\immediate\openout\aux=\jobname.aux

% Cross-reference generation and access macros

% Write a label to the cross-reference file
\def\label#1#2{\immediate\write\aux
{\noexpand\def\expandafter\noexpand\csname#2\endcsname{{#1}{\folio}}}}

% Extract reference part of cross-reference
\def\ref#1{\ifundefined{#1}\message{! No ref. to #1;}%
 \else\expandafter\firstparam\csname #1\endcsname\fi}

% Extract page number part of cross-reference
\def\pageref#1{\ifundefined{#1}\message{! No ref. to #1;}\else%
 \expandafter\secondparam\csname #1\endcsname\fi}

%%% Set up headers and footers
\newtoks\evenpagehead
\newtoks\oddpagehead
\footline={}
\headline={\ifodd\pageno\the\oddpagehead\else\the\evenpagehead\fi}
\evenpagehead={}
\oddpagehead={}

%%% Default paragraph format
\parindent=0pt
\parskip=12pt

%%% Margins
\voffset=.8in

%%% Title page %%%
\chapterfont
\null
\vfill
\centerline{Technical Memorandum}
\centerline{XXXXX EDD}
\vfill
\vfill
\eject

% Table of Contents entry macros
\def\ch#1:#2\page#3\\{\bigbreak\noindent\tocchapterfont#1\ #2\hfill#3\par}
\def\se#1:#2\page#3\\{\noindent\sectionfont\hskip2em#1\ #2\hfill#3\par}
\def\ss#1:#2\page#3\\{\ssectionfont\hskip3em#1\ #2\hfill#3\par}

% Load and then create table of contents file
\newread\toc \immediate\openin\toc=\jobname.toc
\ifeof\toc
 \message{! No file \jobname.toc;}
\else
 \forceodd\chapterfont\noindent Contents\par\textfont  \input\jobname.toc \vfill\eject
\fi
\newwrite\toc
\immediate\openout\toc=\jobname.toc

% List of figures entry macro
\def\fg#1:#2\page#3\\{\noindent\sectionfont\hskip2em#1\ #2\hfill#3\par}

% Load and then create list of figures file
\newread\lof \immediate\openin\lof=\jobname.lof
\ifeof\lof
 \message{! No file \jobname.lof;}
\else
 \forceodd\chapterfont\noindent Figures\par\textfont  \input\jobname.lof \vfill\eject
\fi
\newwrite\lof
\immediate\openout\lof=\jobname.lof

% List of tables entry macro
\def\tb#1:#2\page#3\\{\noindent\sectionfont\hskip2em#1\ #2\hfill#3\par}

% Load and then create list of tables file
\newread\lot \immediate\openin\lot=\jobname.lot
\ifeof\lot
 \message{! No file \jobname.lot;}
\else
 \forceodd\chapterfont\noindent Tables\par\textfont  \input\jobname.lot \vfill\eject
\fi
\newwrite\lot
\immediate\openout\lot=\jobname.lot

% Figure tagging macro
\newcount\fignum\fignum=0
\def\figure#1#2{\advance\fignum by 1 \label{\the\fignum}{#1}{Figure \the\fignum \ #2}
\edef\save{\string\fg\the\fignum:#2\string\page\noexpand\folio%
 \string\\}
\write\lof\expandafter{\save}}

% Table tagging macro
\newcount\tablenum\tablenum=0
\def\table#1#2{\advance\tablenum by 1 \label{\the\tablenum}{#1}{Table \the\tablenum \ #2}
\edef\save{\string\tb\the\tablenum:#2\string\page\noexpand\folio%
 \string\\}
\write\lot\expandafter{\save}}

\newcount\chnum\chnum=0 \newcount\snum \newcount\ssnum

% Chapter tagging macro
\def\chapter#1{\advance\chnum by 1 \snum=0 \edef\lblitem{\chnum}
{\vfill\eject\forceodd\chapterfont \bigbreak\bigskip\noindent\the\chnum. #1 \bigskip\nobreak}
\edef\save{\string\ch\the\chnum:#1\string\page\noexpand\folio%
 \string\\}
\write\toc\expandafter{\save}}

% Section tagging macro
\def\section#1{\advance\snum 1 \ssnum=0 \edef\lblitem{\the\chnum.\the\snum}{\sectionfont\medbreak\smallskip
\noindent\the\chnum.\the\snum\ #1\smallskip\nobreak}
\edef\save{\string\se\the\chnum.\the\snum:%
#1\string\page\noexpand\folio\string\\}
\write\toc\expandafter{\save}}

% Subsection tagging macro
\def\ssection#1{\advance\ssnum by 1 \edef\lblitem{\the\chnum.\the\snum.\the\ssnum}{\ssectionfont\medbreak\smallskip
\noindent\the\chnum.\the\snum.\the\ssnum\ #1 \nobreak\smallskip%
 \nobreak}
\edef\save{\string\ss\the\chnum.\the\snum.\the\ssnum:%
#1\string\page\noexpand\folio\string\\}
\write\toc\expandafter{\save}}

% Start of body
\forceodd
\evenpagehead={\textfont\folio\hfil Joe Allen}
\oddpagehead={\textfont Joe Allen\hfil\folio}
\footline={\textfont\hfil \copyright 2000 Avici Systems Inc.\hfil}
\pageno=1
\textfont

%%% Body %%%
\chapter{Introduction}

This is a test of the TeX system.  Now is the time for all good men to come
to the aid of their country.  Four score and seven years ago our forefathers
decided to come here and kick some ass!

This is a second paragraph.  Now is the time for all good men to come to the
aid of their country.  This is a test of this little thing.  Foo!  See
section \ref{xxx} on page \pageref{xxx}.

\medskip
\table{first}{Example Table}

\smallskip
\vbox{\lineskiplimit=1000pt
\def\strut{\vrule height 10.5pt depth 5.5pt width 0pt}
\tabskip=0pt\halign to \hsize{
\strut#&\vrule width 1pt#&\hbox to 1in {\hfil #}\quad&\null\hskip .25pt\vrule width .5pt\hskip .25pt\null#&\hbox to 1.5in {\hfil #}\quad&\null\hskip .25pt\vrule width .5pt\hskip .25pt\null#&\quad#\hfil\tabskip .2in plus 10in&\vrule width 1pt#\tabskip=0pt\cr
\noalign{\hrule height 1pt}
&&\bf first&&\bf second&&\bf third&\cr
\noalign{\hrule height 1pt}
&&entry&&second entry&&third entry&\cr
\noalign{\hrule}
&&one&&{\vbox{\hsize=1in\raggedleft{\smallskip\parskip=0pt\lineskiplimit=0pt This is a paragraph in a table.\par}}}&&three&\cr
\noalign{\hrule}
&&long line&&second long line&&third long line&\cr
\noalign{\hrule height 1pt}
}}

End of table.  Lets try a figure inclusion.

\medskip
\table{second}{Another example table}

\smallskip
\vbox{\lineskiplimit=1000pt
\def\strut{\vrule height 10.5pt depth 5.5pt width 0pt}
\tabskip=0pt\halign to \hsize{
\strut#&\vrule width 1pt#&\hbox to 1in {\hfil #}\quad&\null\hskip .25pt\vrule width .5pt\hskip .25pt\null#&\hbox to 1.5in {\hfil #}\quad&\null\hskip .25pt\vrule width .5pt\hskip .25pt\null#&\quad#\hfil\tabskip .2in plus 10in&\vrule width 1pt#\tabskip=0pt\cr
\noalign{\hrule height 1pt}
&&\bf first&&\bf second&&\bf third&\cr
\noalign{\hrule height 1pt}
&&entry&&second entry&&third entry&\cr
\noalign{\hrule}
&&one&&{\vbox{\hsize=1in\raggedleft{\smallskip\parskip=0pt\lineskiplimit=0pt This is a paragraph in a table.\par}}}&&three&\cr
\noalign{\hrule}
&&long line&&second long line&&third long line&\cr
\noalign{\hrule height 1pt}
}}

End of table.  Lets try a figure inclusion.

Actually lets see if paragraph spacing is still working.  Now is the time
for all good men to come to the aid of their country.  Four score and seven
years ago blah blah blah.

\bigskip
\line{\hss\vbox{\hbox{\epsffile{fred.eps}\hfill}\hbox{\figure{yyy}{Example Figure}\hfill}}\hss}

Text which follows a figure.

\vfill\eject
\chapter{Requirements}

\section{Physical}
\ssection{Boxiness}
\label{\lblitem}{xxx}
\section{Electrical}
\chapter{Big description}

See figure \ref{yyy} on page \pageref{yyy}.  Also see table \ref{first} on
page \pageref{first}.

\bye
-- 
/*  jhallen@world.std.com (192.74.137.5) */               /* Joseph H. Allen */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}
Technical Details
Message-ID: <FxJJ9I.1BK@world.std.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <FxAAsI.D5p@world.std.com> <3969BF3B.C18583B0@gdn.dsi.unifi.it> <slrn8mmfq5.6qb.mdw@mull.ncipher.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f9e16,4b3cd7e7e2dd6889
X-Google-Attributes: gidf9e16,public
X-Google-Thread: 109f73,4b3cd7e7e2dd6889
X-Google-Attributes: gid109f73,public
X-Google-Thread: 1025b4,4b3cd7e7e2dd6889
X-Google-Attributes: gid1025b4,public
From: jhallen@world.std.com (Joseph H Allen)
Subject: Re: texinfo tables with borders
Date: 2000/07/11
Message-ID: <FxJJ9I.1BK@world.std.com>
X-Deja-AN: 645086174
References: <FxAAsI.D5p@world.std.com> <3969BF3B.C18583B0@gdn.dsi.unifi.it> <slrn8mmfq5.6qb.mdw@mull.ncipher.com>
Organization: The World Public Access UNIX, Brookline, MA
Newsgroups: comp.text.tex,gnu.utils.help,gnu.misc.discuss