[comp.text.tex] Two problems with my directory format

xiaofei@acsu.buffalo.edu (Xiaofei Wang) (02/12/91)

The following is the directory format I used. It is so simple that it
is hardly a format. It has two features: Two column and
each line is indeed appears as a line [without joining lines together.] 
The minor problem is that the blank that falls in the first line
of the first column of a new page appears literally as a blank line
which should be avoided. I would appreciate it if some one can provide
a solution. Another thing is one has to enter the directory entry
alphabetically manually. [I looked the phone.tex and my impression is
it does not have ``auto ordering'' feature.]

\input eplain
\headline={\sl My Diretory\hfil}
\centerline{My Directory}
\centerline{Xiaofei Wang}

\doublecolumns
{\catcode`\^^M=\active \def^^M{\hbox{}\par\parindent=0 pt}\parindent=0 pt%
%/ *
%above line was from baronov@polyof.poly.edu with my modification, i.e. 
%the two parindent lines.
% */
american national standards institute, inc.
sales dept.
1430 broadway
new york, ny 10018
phone 212-354-3300
ask for ansi x3.9-1978, "programming language fortran".
price is now \$35.00 + shipping

american express                                                         
1-800-528-4800                                                          

amnesty international                                                    
212-864-6109                                                            
us coordinate on china;535 w 110 st, apt 9d;
new york, ny 10025           
coordinator.rosalie lipsett                                                   
}
\singlecolumn
\end
-- 
xiaofei@acsu.buffalo.edu / rutgers!ub!xiaofei / v118raqa@ubvms.bitnet

em@dce.ie (Eamonn McManus) (02/13/91)

xiaofei@acsu.buffalo.edu (Xiaofei Wang) writes:
>Another thing is one has to enter the directory entry
>alphabetically manually. [I looked the phone.tex and my impression is
>it does not have ``auto ordering'' feature.]

Since TeX does not have primitives to compare two strings except for
equality, it is difficult to use it to do ordering.  Besides, doing it by
hand means that you can deal with peculiarities of your national language,
or put names with the forename first even though they are sorted by the
surname.

Of course, it's *possible* to write macros to compare strings (naively) and
to sort entries (e.g., by building a binary tree as the entries are read);
it's just not the sort of thing that's best done in TeX.

Here are some macros I wrote some time ago to compare strings
alphabetically.  \compare{string1}{string2} expands to 0, -1, or 1,
according as string1 is the same as, less than, or greater than string2,
respectively.  Both strings should consist entirely of plain characters
(not control sequences).

I took care that the comparison is done entirely in TeX's `mouth', so this
macro can be used in \ifnum and the like.

,
Eamonn

% compare.tex - macro to compare two strings
% By \'Eamonn McManus.  This file is not copyrighted.

\def\compare#1#2{\compcont#1\ \\#2\ \\}
\def\compcont#1#2\\#3#4\\{%
     \csname comp%
       \if #1#3\if #1\ same\else cont\fi
       \else \ifnum `#1<`#3less\else greater\fi \fi
     \endcsname #2\\#4\\}
\def\compsame#1\\#2\\{0}
\def\compless#1\\#2\\{-1}
\def\compgreater#1\\#2\\{1}