******************************************************************************* * * * TTTTTTT X X M M GGGGGG A Mostly Unofficial * * T X X MM MM G Publication for Users * * T EEEEEEE XXX M M M M A G GG Of the TeX Computer * * T E X X M M M A A G G Typesetting System. * * T EEEE X X M M M AAAAA GGGGGG * * E A A Volume 1, Number 7 * * EEEEEEE A A Distribution: 346 or so... * * * ******************************************************************************* October 11, 1987 Contents: \footnote............................................................1 Fill-in-the-blanks typesetting.......................................2 Outline formatting in TeX............................................3 A TeX previewer for VM/CMS...........................................4 Time lines...........................................................5 The Toolbox..........................................................6 __1 \footnote{Call me irresponsible} OK, I'm a month late with this issue. However, I managed to get it done somehow. Anyway, I've fiddled with the formatting of the issue again. The changes are pretty obvious so I won't describe them. This issue, despite its lateness is one of the more information- packed issues to come out in some time, thanks to the generous contributions of Hal Varian who has given us some macros for fill-in- the-blanks formatting and outlines. Also in this issue is the formal announcement of the previewer I wrote over the summer (remember my hinting at that last issue? It's ready to go now) a macro for drawing time lines, and the usual toolbox. By the way, if you're a new subscriber to TeXMaG, let me summarize a common theme from back issues: PLEEEEASE SEND ARTICLES! :-) G'day -dh __2 *Fill in the blanks macro for TeX* By Hal Varian The following macros generate "fill-in-the-blanks" of an appropriate size for the answer. Unfortunately, they don't handle math mode. If anyone has a way to get this sort of thing working for math mode, I would be very interested in hearing about it. %%%--------------------------cut here------------------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Fill-in-the-blank macros % Hal Varian % August 19, 1987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %list processing routines taken from TeXbook, p. 310-11 \def\dolist{\afterassignment\dodolist\let\next= } \def\dodolist{\ifx\next\endlist \let\next\relax \else \\\let\next\dolist \fi \next} \def\endlist{\endlist} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %print out answers or not? \newif\ifDoAnswers\DoAnswerstrue %See if next token is a space. If it is, set a low penalty for %line breaking. Set box 0 to be the next token. If we should %do answers, underscore box 0, back up and print box 0. Otherwise %just underscore box 0. \def\\{\expandafter\if\space\next\penalty0\fi\setbox0=\hbox{\next}\ifDoAnswers \underscore\llap{\raise2pt\box0}\else\underscore\fi} %Underscore -- put in strut so there is enough space for handwriting. \def\underscore{\bigstrut\vrule height 0pt depth.5pt width\wd0} \def\bigstrut{\hbox{\vrule height 16pt width 0pt}} \def\Ans#1{\space{\AnsFont {\dolist#1\endlist}\underscore}} %%% ----cutting here would not be a bad idea----------------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Example of use of macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \magnification=\magstephalf \font\AnsFont=cmtt10 at 14pt \parskip=1pc \parindent=15pt \newcount\QuestionNumber \QuestionNumber=1 \def\Question{\hangindent\parindent\ignorespaces\noindent\number \QuestionNumber.\space \advance\QuestionNumber by 1} \DoAnswerstrue \noindent{\bf With Answers:} \medskip \Question If all men are mortal, and Socrates is a man then \Ans{Socrates is mortal man, as well as a Greek man}. \Question Five time four equals \Ans{20.} \Question Mares eat \Ans{oats}, and does eat \Ans{oats}, and little lambs eat \Ans{ivy}. I would eat ivy too, \Ans{wouldn't you}? \DoAnswersfalse \QuestionNumber=1 \bigskip \noindent{\bf Without Answers:} \medskip \Question If all men are mortal, and Socrates is a man then \Ans{Socrates is mortal man, as well as a Greek man}. \Question Five time four equals \Ans{20.} \Question Mares eat \Ans{oats}, and does eat \Ans{oats}, and little lambs eat \Ans{ivy}. A kid'll eat ivy too, \Ans{would you}? \bye __3 *TeX outlines from PC-OUTLINE output* By Hal Varian [[Editor's note: There were no accompanying notes with this macro other than the comments at the beginning of the file. Despite the fact that Hal has used .sty as the extension for his file, it seems to be a macro for plain TeX. The implementation of \head X where X is a number indicating the ``level'' of the head is rather interesting and should serve as a good model for macros that are used in translations of other formatting languages.]] %%%-Sever------------------------------------------------------------ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % outline.sty -- Outline Style % Hal R. Varian % September, 1987 % % Reads structured files generated by PC-OUTLINE and formats them % in TeX. Before using you must use a global search and replace command % to change all strings of ".HEAD" to "\HEAD". Then load outline.sty % and TeX the outline file. % % Notes % 1. To generate the outline, choose "Send to structured file" from the % device menu in the print routine of PC-OUTLINE. % 2. The title must be indicated manually using \title. It is usually % indicated by a .HEAD 1 % 3. Sometimes the structured file ends with a spurious .HEAD 1 which should % be removed. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %for title \def\title#1{\centerline{\bf #1}\medskip} %use \count11 thru \count18 for counters for levels 1 thru 8 \count11=0 \count12=0 \count13=0 \count14=0 \count15=0 \count16=0 \count17=0 \count18=0 %create registers for levels, etc. \newcount\CurrentLevel\CurrentLevel=0 \newcount\LastLevel\LastLevel=0 \newcount\CurrentCounter\CurrentCounter=1 \newcount\CharCode\CharCode=96 %\Indentation measures the amount of indentation \newdimen\Indentation\Indentation=3ex %skip between level 1 headings \def\AdjustSpace{\vskip -.5pc} \parindent=0pt \parskip=0pt \def\HEAD #1 {% \par \CurrentLevel=#1 \CurrentCounter=#1 \advance\CurrentCounter by 10 %level 1 is assigned to register 11, etc. \ifnum\CurrentLevel>\LastLevel %if sublevel, \count\CurrentCounter=1 %reset \CurrentCounter, \else\advance\count\CurrentCounter by 1\fi %otherwise, increment \LastLevel=\CurrentLevel \filbreak %helps prevent entries from being split between pages \hskip\CurrentLevel\Indentation \CharCode=\number\count\CurrentCounter %for lettered levels \let\NumCode=\CharCode %for numbered levels \ifcase#1% \relax\or %there is no level zero \AdjustSpace\advance\CharCode by 64 \Item\char\CharCode.\space\or %level 1: A. \Item\llap{\number\NumCode.\space}\or %level 2: 1. \advance\CharCode by 96 \Item\llap{\char\CharCode)\space}\or %level 3: a) \Item\llap{\number\NumCode)\space}\or %level 4: 1) \advance\CharCode by 96 \Item\llap{\char\CharCode$>$\space}\or %level 5: a> \Item\llap{\number\NumCode$>$\space}\or %level 6: 1> \advance\CharCode by 96 \Item\llap{\char\CharCode:\space}\or %level 7: a: \Item\llap{\number\NumCode:\space}\fi} %level 8: 1: \def\Item{\hangindent\CurrentLevel\Indentation} %%%-Incise---------------------------------------------------------- __4 *A screen previewer for VM/CMS* By Don Hosek A good previewer is a useful tool for working with TeX, but unfortunately, there are very few available. For users of TeX under the IBM VM/CMS system, the only choice available once was DVI82, a Versatec driver, that, as an added feature allowed previewing on IBM 3279 and 3179-G terminals. To deal with this situation, I wrote DVIview, a TeX previewer that displays its output on VT640-compatible displays connected to an IBM mainframe via either a 3705 controller or a Series-1/7171 protocol converter. In addition, the output routines are modularized enough that it should be a fairly simple task to modify the program to drive any graphics terminal connected to the mainframe. (I have plans to include support for GDDM-driven displays in the near future). DVIview is a lengthy WEB program that interprets the instructions in a DVI file and displays them on the user's screen as determined by commands typed at the keyboard. The entire page may be viewed with block outlines of the characters, or smaller portions of the page may be selected and viewed using the actual shapes of the TeX fonts. Font information is read from PK files (I cannot recommend the PK format enough to people writing new device drivers; the fonts take roughly half the space of GF files and about and about a third the space of PXL files. And PK readers are easier to write!). The DVIview distribution includes two manuals: "Previewing TeX Output With DVIview" is the users' guide and explains how to use the program from a users standpoint. Also included is "Installing and Customizing DVIview", intended for the systems person who installs DVIview. Instructions are given for installing DVIview as is, as well as instructions on adding changes to the file and a "Hitchhikers' Guide to WEB" (for those who don't care how they get where they're going as long as they don't have to ride the bus). Due to the size of the program, it cannot be distributed over the networks. To obtain a copy of DVIview and its documentation, send $30 (to defray duplication costs), a blank tape, and a return mailer to: Don Hosek Platt Campus Center Harvey Mudd College Claremont, CA 91711 The program is public domain, so feel free to give it away. However, since it is still a young program, I'd like to keep track of who has copies for purposes of distributing updates. __5 *Timelines with plain TeX and LaTeX* By Don Hosek In the most recent issue of TUGboat (Vol. 8 No. 2), there was a query for a macro to draw time lines in TeX. At the time, I had just finished writing DVIview (see the related article this issue) and was waiting for bugs to surface and my paycheck to arrive with little else to do, so I decided to tackle the problem. To make the problem more interesting, I decided to make the macro work in both LaTeX *and* plain TeX. A sample input file should look something like: %%% Cut here------------------------------------------------------ %%% LaTeX sample \documentstyle[timeline]{article} \def\TeXMaG{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX% TeX part M\kern-.1667em\lower.5ex\hbox{A}\kern-.2267emG} \begin{document} This is a timeline of the history of \TeXMaG. \begin{timeline}{2in}(0,180) \optrule \item[12]{Jan. 24}{Volume 1, Number 1} \item[33]{Mar. 6}{Volume 1, Number 2} \item[43]{Mar. 25}{Volume 1, Number 3} \item[81]{May. 13}{Volume 1, Number 4} \item[102]{Jun. 25}{Volume 1, Number 5} \item[132]{Aug. 24}{Volume 1, Number 6} \item[160]{Oct. 10}{Volume 1, Number 7} \item[179]{Dec. 31}{The distant future} \end{timeline}%% There needs to be a comment here, unfortunately. This text should not be indented at all. I'm going to keep on going to see what happens, because the best way to test these things is to have the text longer than one line. \end{document} %%% Rrrrrip----------------------------------------------------------- Or something similar in plain TeX. In the example above, I used sort keys to control the spacing between entries. I also could have had a timeline whose entries looked like this: \item{1776}{Declaration of Independence} \item{1812}{War of 1812} \item{1849}{Gold rush of '49} \item[1862]{1862--5}{Civil War} . . . Where the dates themselves control the placement. Note that the entry for the Civil War uses a sort key to allow the year to be 1862--5. This was a pretty big problem. The comments below give a fair idea of how to *use* the macro; the remainder of this article will deal with how the macros themselves *work*. First of all, it helps to have some idea of how \begin{...} and \end{...} work in LaTeX. To view it in a simplified form, when the command \begin{NAME} is invoked, LaTeX issues the commands \begingroup followed by \NAME; similarly, \end{NAME} issues the commands \endNAME followed by \endgroup. Therefore, to allow an environment to function in plain TeX, all we need to do is include an extra grouping with \NAME...\endNAME and provide copies of any LaTeX internal macros used by the environment. Both of these tasks are fairly simple, and in the timeline macros, the only LaTeX internal macro called is \@ifnextchar (this is a very handy macro for many reasons, and gives some insight into the mysteries of LaTeX). \@ifnextchar is called in a general form of \@ifnextchar X{YES}{NO} (by the way, the explanations for LaTeX's internals are in the file LATEX.TEX which is included with almost all TeX distributions). The timeline macros use this for \item to check to see if the optional argument (enclosed in []s) is present. If the next character after \@ifnextchar matches X (X cannot be a space) then YES is executed, otherwise NO is executed. In the specific case here, this is done with the call \@ifnextchar[\@item\@itemnosrtkey, which calls \@item if the optional argument is present, and \@itemnosrtkey if it isn't. In addition, the character that is tested remains in the input stream, so \@item has a parameter list that looks like \@item[#1]#2#3 rather than \@item#1]#2#3. The definition of \item for the timeline macros is kept local so it won't interfere with other uses of that control sequence name by either plain or La- TeX. The main work of this is done by \@item, which takes three arguments: the first argument is used to determine the vertical placement of the timeline item, the second argument is the nominal date and the third a description. \@itemnosrtkey calls \@item using the nominal date as the first argument as well. The placement of the item on the timeline is determined by taking the date number (first parameter) and converting to a number between 0 and the length of the timeline as specified with the arguments to the \timeline (\begin{timeline}) macro. This number is then multiplied by 1/65536 times the length of the timeline as specified by the user. The factor of 1/65536 prevents an arithmetic overflow from occuring at the cost of reducing accuracy (measurements are only kept accurate to one point). Finally, this number is divided by the length of the range of date number values and then by 65536 which gives a dimension specifying how far down from the top of the timeline the entry should be placed. The actual placement is accomplished with the \dlap macro from the toolbox of V1N3. By placing the necessary text after a vertical \kern, inside a vertical lap, we are able to print information anywhere on the timeline without changing our vertical position. This does have the disadvantage of using a lot of box memory and may run into problems with very complicated time lines, but it seemed like a good idea at the time. The final interesting facet of the macros is the (simple) way that two entries that are close together are resolved. After an entry is printed, the vertical dimension specifying its placement is stored in the dimen register \itwashere. When the next entry is to be printed, the current vertical placement is compared to \itwashere if the difference is less than 12pt, and the entry would normally be placed on the left, then the entry is printed on the right. Otherwise it is printed on the left. This algorythim works well for two closely placed entries but fails for three closely placed entries (the two on the left will likely overlap). The macros presented work for simple time lines, but problably will be deficient for more complex time lines. Hopefully, this explanation of the macros will help in customizing them for your own purpose, or in writing a time line macro of your own. %%% Slice------------------------------------------------------------ %%% File: Timeline.Sty %%% Written to work with either LaTeX or plain TeX %%% %%% In LaTeX: %%% \begin{timeline}{length}(start,stop) %%% . %%% . %%% . %%% \end{timeline} %%% %%% in plain TeX %%% \timeline{length}(start,stop) %%% . %%% . %%% . %%% \endtimeline %%% in between the two, we may have: %%% \item{date}{description} %%% \item[sortkey]{date}{description} %%% \optrule %%% %%% the options to timeline are: %%% length The amount of vertical space that the timeline should %%% use. %%% (start,stop) indicate the range of the timeline. All dates or %%% sortkeys should lie in the range [start,stop] %%% %%% \item without the sort key expects date to be a number (such as a %%% year). %%% \item with the sort key expects the sort key to be a number; date %%% can be anything. This can be used for log scale time lines %%% or dates that include months or days. %%% putting \optrule inside of the timeline environment will cause a %%% vertical rule to be drawn down the center of the timeline. \catcode`\@=11 % Pretend @ is a letter \newcount\startat \newcount\tllength \newdimen\putithere \newdimen\itwasthere \newcount\scr@tchi \newdimen\scr@tchii % A vertically centered lap \long\def\ylap#1{\vbox to \z@{\vss#1\vss}} % Vertical `laps'; cf. \llap and \rlap \long\def\ulap#1{\vbox to \z@{\vss#1}} \long\def\dlap#1{\vbox to \z@{#1\vss}} \def\timeline#1(#2,#3){\ifvmode\else\par\fi$$\vbox to#1\bgroup % The \vbox command is % surrounded by $$..$$ to make it % fit in well with paragraphs. \offinterlineskip \startat=#2\tllength=#3 \advance\tllength by-\startat % \tllength should be the total % length of the timeline. \def\item{\@ifnextchar[\@item\@itemnosrtkey} \def\@item[##1]##2##3{\scr@tchi=##1 \advance\scr@tchi by-\startat \putithere=#1 \divide\putithere by 65536 % to avoid arithmetic % overflow \multiply\putithere by \scr@tchi % we only remain \divide\putithere by\tllength % accurate to 1pt in \multiply\putithere by 65536 % these calculations % Now \putithere has how far % down we should go for this item. \scr@tchii=\putithere \advance\scr@tchii by -\itwasthere \ifdim\scr@tchii<12pt \ifx\lrswitch L \@putright{\putithere}{##2}{##3} \else \@putleft{\putithere}{##2}{##3} \fi \else \@putleft{\putithere}{##2}{##3} \fi \itwasthere=\putithere } \def\@itemnosrtkey##1##2{\@item[##1]{##1}{##2}} \def\@putright##1##2##3{\dlap {\kern##1\centerline {\rlap {\ $\bullet$\hskip1.5em{\bf ##2} \ ##3}}} \let\lrswitch=R } \def\@putleft##1##2##3{\dlap {\kern##1\centerline {\llap {{\bf ##2} \ ##3\hskip1.5em$\bullet$\ }}} \let\lrswitch=L } \def\optrule{\dlap {\centerline {\dimen0=#1 \advance\dimen0 by 6pt % This calculation is % kept local \vrule depth \dimen0 height-6pt}} } } \def\endtimeline{\vfill\egroup\vbox{\vskip\baselineskip}$$} % Put the extra \vskip in a \vbox to hide it from % the math gods. \ifx\@latexerr\undefined \def\@ifnextchar#1#2#3{\let\@tempe #1\def\@tempa{#2}\def\@tempb{#3} \futurelet\@tempc\@ifnch} \def\@ifnch{\ifx \@tempc \@sptoken \let\@tempd\@xifnch \else \ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb \fi \fi \@tempd} % NOTE: the following hacking must precede the definition of \: % as math medium space. \def\:{\let\@sptoken= } \: % this makes \@sptoken a space token \def\:{\@xifnch} \expandafter\def\: {\futurelet\@tempc\@ifnch} \catcode`\@=12 % Let's not pretend @ is a letter \fi %%% Divide electronically------------------------------------------- __6 *The Toolbox* This issue, I only have two macros to share: the first is a unary "not" symbol using a tilde-like character. (I happened to need this for my discrete math course). The macro is named \unot to distinguish it from \not which produces a slash through a relational operator (as in \not=, &c.). %%%-Some synonym for cut--------------------------------------------- \def\unot{\mathop{\sim}} %%%-Likewise--------------------------------------------------------- Second up at bat is a macro to print the Pascal text of a WEB program in sans-serif type rather than the italic type used by WEBMAC. I did this to demonstrate the flexibility of WEAVE's formatting to a friend and decided that I liked sans-serif Pascal text better. %%%-This is the unkindest cut here of all---------------------------- % This is WEBMACss.TEX in text format, as of Aug 27, 1987. % modification to standard macros for WEB listings (in addition to % PLAIN.TEX) % Prints Pascal text in sans-serif type. % To use, include the line \input WEBMACss.TeX in the ``limbo'' % section of your WEB program \font\pit=cmss10 % type for identifiers \font\pbf=cmssbx10 % type for reserved words. \def\\#1{\hbox{\pit#1\/\kern.05em}} % italic type for identifiers %\def\|#1{\hbox{$#1$}} % one-letter identifiers look a bit better this way \let\|=\\ % We aren't using \mit anymore. \def\{\hbox{\pbf#1\/}} % boldface type for reserved words %%%-Julius Caeser never really said that----------------------------- __7 TeXMaG is an electronic magazine published by the Harvey Mudd College Mathematics Department available free of charge to all interested parties reachable by electronic mail. It is published sporadicly, and the editor likes to think that its monthly so the readers humor him. Subscription requests should be sent to Don Hosek or send the following message to LISTSERV@BYUADMIN: SUBS TEXMAG-L Your_Full_Name. European subscribers may send the SUBS command to LISTSERV@DEARN, subscribers on CDNnet should send subscription requests to (being sure to mention that they wish to subscribe to TeXMaG), and JANET subscribers should send requests to be added to the list to Peter Abbott, . Back issues are available for anonymous FTP in the file BBD:TEXMAG.TXT on SCIENCE.UTAH.EDU. They may also be obtained from Don Hosek . Article submissions, contributions for the Toolbox, and letters to the editor are always welcome and should be sent to . Other publications of interest to TeX users are: TeXHAX. Arpanet mailing list for persons with questions, suggestions, etc.. about TeX, LaTeX, MetaFont and related programs. Submissions for this list should be sent to . BITNET users may subscribe by sending the following command (as an interactive message or as the first line of a mail message) to LISTSERV@TAMVM1: SUBS TEX-L your_full_name. The list is peer-linked to other listserves in the United States and Europe. Internet subscribers may subscribe by sending a request to . The TeX-L mailing list is a ``hybrid;'' i.e., it is both an ARPAnet redistribution, and a BITNET discussion list. Submissions for TeX-L (only --- they will _not_ be forwarded to TeXHAX) may be sent to TeX-L@TAMVM1. LISTSERV@TAMVM1 also has file archives that may be of interest to TeX users on BITNET, including the files from the SU-SCORE FTP directories and back issues of TeXHAX. For a list of files available, send the following command to LISTSERV@TAMVM1: GET TeX FILELIST. Unix-TeX. Arpanet mailing list specifically for users of TeX under the Unix operating system. Submissions for this list should be sent to . Requests to be added or deleted from the mailing list should be sent to . TUGBoat. A publication by the TeX Users Group. An excellant reference for TeX users. For more information about joining TUG and subscribing to TUGBoat send (real) mail to: TeX Users Group c/o American Mathematical Society P. O. Box 9506 Providence, RI 02940-9506, USA Special thanks to everyone for not flooding me with mail saying "WHERE'S MY TEXMAG?", and to Dean Bell.