UKTeX Digest Friday, 20 Nov 1992 Volume 92 : Issue 43 ``The UKTeX Digest is brought to you as a free, unfunded and voluntary service of the UK TeX Users Group and the UK TeX Archive.'' Today's Topics: {Q&A}: Bringing back hanging re: Bring back hanging RE: Bring back hanging Re: Bring Back hanging TeX variable scope rules (was: another gem) Double-sided printing and page-imposition in LaTeX Administrivia: Moderators: Peter Abbott (Aston University) and David Osborne (University of Nottingham) Contributions: UKTeX@uk.ac.tex Administration, subscription and unsubscription requests: UKTeX-request@uk.ac.tex ------------------------------------------------------------ Date: Sun, 15 Nov 92 10:56:38 -0500 From: Jerry Leichter Subject: Bringing back hanging In a recent UKTeX, R.A. Reese has two questions. First, he attempts to make every paragraph a hanging paragraph by executing \everypar{\hang} This works fine until he starts a paragraph with a font shift: This paragraph has hanging indentation. {\bf This} paragraph should be similar to the first, but it is not; it does not have hanging indentation. What is going on is quite simple. Let's look at the first paragraph. TeX is in vertical mode when it reaches the "T". Since a is "incompatible with vertical mode" (ref. the TeXbook, page 283). TeX responds by effectively performing an \indent command before returning to deal with the "T". The \indent command (a) inserts \parskip glue (in most cases, see page 282 for details); (b) enters unrestricted horizontal mode; (c) adds an empty hbox of width \parindent to the new horizonal list; (d) inserts the \everypar tokens into the input stream, where they will be seen before the still-waiting "T"; (e) exercises the page builder. When the page builder is finished, the tokens from \everypar are read, in this case setting \hangindent. Eventually, we reach the end of the paragraph. It is set indented (since \hangindent is set) and \hangindent is reset to 0pt. Now consider the second paragraph. We start out in vertical mode again. The first thing we see is "{". TeX starts a new group, and remains in vertical mode. Next, we see \bf. TeX expands this, changing the current font; it is still in vertical mode, since nothing in the expansion of \bf should cause it to change. Finally, it sees the "T", and goes through the same five steps as previously. \hangindent is set as before, and "This" is typeset in bold- face. Now we reach "}". This ends the group. As part of ending the group, the previous value of \hangindent (0pt) is restored. When we eventually reach the end of the paragraph, the value of \hangindent set by the \everypar is long gone, and it is the value THEN that determines how the paragraph should be typeset. This kind of thing is a recurring problem with the \everypar mechanism: It's always essential to remember that the \everypar tokens may be interpreted within a group - in fact, within arbitrarily many groups, since the input could have been: {{{\bf This}}} is strange by legal. One way to get around this is to use \global\hang. (This works because \hang is just \hangindent\parindent, so the \global applies to the stuff "inside" with no problem. Admittedly, as a general practice such reliance on what a macro translates to is a bad idea - much better to use: \everypar{\global\hangindent\parindent} which works as well but is independent of the innards of \hang.) The only other fix requires an explicit \indent or \noindent at the beginning of paragraphs that start with "{". In a second question (which, as we've seen, is actually closely related to the first), Mr. Reese comments that: ...Scoping is fine but TeX's rules are not the same as proper scoping in an algorithmic language. If you "declare a variable" it stays in scope for all inferior blocks unless the name has been reused. TeX is following the Fortran tradition here where variables are implicitly local unless made global... Well, no. There have been two general kinds of scoping rules used in program- ming languages, static (lexical) scoping and dynamic scoping. ALGOL 60 and languages derived from it use lexical scoping. LISP, APL, and SNOBOL are examples of languages that use dynamic scoping. Lexical scoping has tradi- tionally been associated with compilers. Dynamic scoping has traditionally been associated with interpreters. (This distinction has broken down to a degree with lexically-scoped LISP's, such as SCHEME.) Macro languages are almost always dynamically scoped. In addition, they often do not require variables to be declared before they are used. To accomodate this, many use a variation on dynamic scoping in which a new scope for a variable is begun when it is re-defined within a group. This allows both for nesting of definitions and for the import of definitions from surrounding groups. TeX follows this approach. See any good programming language text for a discussion of the tradeoffs between static and dynamic scoping; the choice is by no means black and white. For a language like C, where the definitions of functions cannot be nested in other functions, a simple stack is sufficient to implement static scoping. For PASCAL, one has to be a bit more clever. For SCHEME, where functions can be defined on the fly, static scoping requires the use of closures, a complex matter. Stacks alone won't do. In TeX, where macros can define other macros, the same would apply. Further, pure static scoping, even after buying in to closures, would have made some other things we are used to doing in TeX quite difficult. Knuth's choice of context style was not arbitrary, nor was it "wrong". It simply made a different set of tradeoffs than others might want to make. On the other hand, knowing the level of Knuth's work, it made the tradeoffs knowingly. -- Jerry ------------------------------ Date: 16 Nov 92 13:58:00 +0000 From: M.Piff@uk.ac.sheffield Subject: re: Bring back hanging R A Reese asks: % Question - what causes the following command to not operate? % From a quick reading of the TeXbook, I'd call it a bug - there's no % reason for the begin-group to affect the change to horizontal mode. \everypar{\hang} This paragraph is a hanging paragraph. Each line after the first is set in by the parindent. Since I didn't change the default, so is the first line. In other words it's a rectangle. {\bf This} paragraph should be similar to the first, but it is not. For some reason I don't understand, starting the paragraph with a brace has stopped the everypar working. So this comes out as a standard paragraph, first line indented, rest flush with left margin. If I just put the font-change command at the start, not in a group, the paragraph hangs again. This {\bf paragraph} does come out hanging, similar to the first. So it is the group character at the point of switching to horizontal mode that causes the problem. Can anyone explain? \bye Consider the following: \everypar{\hang}\tracingrestores=10 {a} \bye \TeX\ only enters horizontal mode when it reads the ``a'', within the group. Thus "\hang" is only executed within that group, and its effect is forgotten by the time \TeX\ breaks the paragraph up into lines. Look at the LOG file: This is emTeX, Version 3.14 [3c-beta5] (preloaded format=plain 92.3.30) 16 NOV 1992 13:49 **reese (reese.tex{restoring \hangindent=0.0pt} %%%<-------------------- {restoring \dimen0=0.0pt} {restoring \boxmaxdepth=16383.99998pt} {restoring current font=\tenrm} {restoring \baselineskip=12.0pt} [1] ) Output written on reese.dvi (1 page, 208 bytes). I expect some would say this is a silly design decision in \TeX. Mike Piff Dr M J Piff JANET: Department of Pure Mathematics pm1mjp%hicks1.shef@sunc.shef.ac.uk University of Sheffield M.Piff@pa.shef.ac.uk Hicks Building Hounsfield Road SHEFFIELD S3 7RH Telephone: SHEFFIELD (0742) 768555 England Ext. 4431 ------------------------------ Date: Mon, 16 Nov 92 14:35:40 +0000 From: Philip Taylor (RHBNC) Subject: RE: Bring back hanging >% Question - what causes the following command to not operate? >% From a quick reading of the TeXbook, I'd call it a bug - there's no >% reason for the begin-group to affect the change to horizontal mode. > >\everypar{\hang} >{\bf This} paragraph should be similar to the first, but it is not. >For some reason I don't understand, starting the paragraph with a >brace has stopped the everypar working. So this comes out as a >standard paragraph, first line indented, rest flush with left margin. >If I just put the font-change command at the start, not in a group, >the paragraph hangs again. On the contrary, \everypar is working perfectly. It is setting the values associated with \hang, and it is setting them within the group started by the open brace of {\bf ...}. On leaving the group, the values are restored to those of the status ante bellum. When the paragraph finally ends, and is set according to its current parameters, TeX has no recollection whatsoever that, for a short period, those values had changed. Philip Taylor, RHBNC. ------------------------------ Date: Mon, 16 Nov 92 14:00:48 +0000 From: Jeremy Henty Subject: Re: Bring Back hanging R.A.Reese writes: |% Question - what causes the following command to not operate? |% From a quick reading of the TeXbook, I'd call it a bug - there's no |% reason for the begin-group to affect the change to horizontal mode. | |\everypar{\hang} | |This paragraph is a hanging paragraph. Each line after the first is |set in by the parindent. Since I didn't change the default, so is the |first line. In other words it's a rectangle. | |{\bf This} paragraph should be similar to the first, but it is not. |For some reason I don't understand, starting the paragraph with a |brace has stopped the everypar working. So this comes out as a |standard paragraph, first line indented, rest flush with left margin. |If I just put the font-change command at the start, not in a group, |the paragraph hangs again. | |This {\bf paragraph} does come out hanging, similar to the first. So |it is the group character at the point of switching to |horizontal mode that causes the problem. Can anyone explain? | |\bye | |(R.) Allan Reese This is not a bug, what is happening is this: When processing ordinary text, TeX does not enter horizontal mode until it encounters a letter. In your troublesome paragraph, the first letter is inside a group, so the \everypar instruction is executed *inside* this group. When the group ends, all local assignments are undone, and the \everypar instruction is forgotten. The solution is to type \indent {\bf This} paragraph ... because \indent forces TeX into horizontal mode (and gets the \everypar instruction executed) *outside* the group. Jeremy C. Henty ------------------------------ Date: Mon, 16 Nov 92 16:54:40 +0000 From: SYSMGR@uk.ac.kcl.ph.ipg Subject: TeX variable scope rules (was: another gem) Allan Reese wrote to point out that when > you "declare a variable" it stays in scope for all inferior blocks unless > the name has been reused. TeX's variable scope rules are shared by several other interpreted languages, such as DCL (the command language on the VAX I'm using). This possibility arise s naturally whenever one has a language in which declarations are executable statements that can be conditionally executed or not at various levels of recursion. It can't happen in a compiled language like C, because a program can't choose to conditionally execute a declaration. Is it worth discussing? Well, it can't be changed, because if it was the result wouldn't be TeX any more. If its a common gotcha, then doubtless raising it will help someone. Yours, Nigel Arnot NRA%ipg.ph.kcl.ac.uk@nsfnet-relay.ac.uk (internet) NRA%uk.ac.kcl.ph.ipg@ukacrl.bitnet (bitnet) ------------------------------ Date: Thu, 19 Nov 92 11:33:05 +0000 From: vdm@le.ac.uk Subject: Double-sided printing and page-imposition in LaTeX A query for (La)TeX experts: Does anyone have modifications to the standard LateX twoside.sty macros for printing documents on a laser printer that does double sided printing. The problem is as follows: the document is large and is printed using \includeonly{...}. With twosided.sty LaTeX generates the extra pages needed to finish off the previous chapter correctly so that the next chapter starts correctly on an odd page (which is what I want). However the extra page goes on the front surface when printing out the chapter and the odd page goes on the back WHICH IS NOT WHAT I WANT. For those supplying solutions 1. I don't wish to fiddle with DVIDVI DVIPS etc - I feel LaTeX should do the work. 2. The document cannot be printed at one go (each chapter uses a different set of incompatible macros). A solution which solves (2) would also be interesting/ welcome!. A futher little challenge: I wish to print out a double sided A5 booklet using the above laser printer - the idea is to print 4 A5 pages per A4 sheet and just fold the result in half. There are two problems: 1. How can dvidvi be made to produce the right re-arrangement. 2. The laser printer prints the back two pages on an A4 sheet upside down! Please note that the printer is remote and belongs to the Computer Center so cannot be fiddled with! Many thanks in advance to suppliers of solutions. From: Derek Andrews Email: JANET : derek@mcs.le.ac.uk Smail: Department of Mathematics and Computer Science University of Leicester University Road Leicester LE1 7RH UK Tel: (+44) 533 523401 Fax: (+44) 533 523604 ------------------------------ UK TeX ARCHIVE at ASTON UNIVERSITY >>> UK.AC.TEX <<< *** Interactive and file transfer access *** JANET: Host: uk.ac.tex, Username: public, Password: public (DTE 000020120091) Internet: host tex.ac.uk [134.151.40.18] For telnet access, login: public, password: public For anonymous ftp, login: anonymous, password: *** Mail server *** Send mail to TeXserver@uk.ac.tex (JANET) or TeXserver@tex.ac.uk (rest of the world) with message body containing the word HELP \section FILES OF INTEREST [tex-archive]00readme.txt [tex-archive]00directory.list [tex-archive]00directory.size [tex-archive]00directory_dates.list [tex-archive]00last30days.files [tex-archive.doc]TeX-FAQ.txt (Frequently Asked Questions list) [tex-archive.doc]FAQ-Supplement-*.txt (FAQ supplement) \section DIGESTS This year's UKTeX back issues are stored in the archive in directory [tex-archive.digests.uktex.92] This year's TeXhax back issues are stored in the archive in directory [tex-archive.digests.texhax.92] Latest TeXhax: V92 #20 TeXMaG back issues are stored in the archive in directory [tex-archive.digests.tex-mag] Latest TeXMaG: V5N3 \section MEDIA DISTRIBUTIONS Postal addresses are given below. \subsection Washington Unix TeX distribution tape Latest copy of May/June 1991 contains: TeX 3.14, LaTeX 2.09, Metafont 2.7, plus many utilities suitable for Unix 4.2/4.3BSD & System V tar format, 1600bpi, blockfactor 20, 1 file (36Mb) Copies available on: One 2400ft 0.5" tape sent to Aston with return labels AND return postage OR One Quarter-Inch Cartridge, QIC-120 or QIC-150 format (DC600A or DC6150) sent with envelope AND stamps for return postage to Nottingham (Due to currency exchange, this service is offered only within the UK) \subsection VMS tapes VMS backup of the archive requires three 2400ft tapes at 6250bpi. VMS backup of TeX 2.991 plus PSprint requires one 2400ft tape. \subsection Exabyte 8mm tapes Same contents available as 0.5" tapes. Following tape types available: SONY Video 8 cassette P5 90MP, MAXELL Video 8 cassette P5-90, TDK Video 8 cassette P5-90MPB \section TeX IMPLEMENTATIONS FOR SMALL COMPUTERS \subsection OzTeX V1.4 (for Macintosh) Send 7 UNFORMATTED 800K disks to Aston with return postage. \subsection emTeX (for OS/2, PC-DOS and MS-DOS) The complete package (3.5" High density disk format ONLY) is available from Aston at a cost of 15 pounds sterling, including documentation, disks, post and packing (DO NOT SEND DISKS): specify Set A. Additional utilities including DVIPS, 5 pounds sterling: specify Set B. FLI files for FX, 5 pounds sterling: specify Set C. FLI files for P6M, 5 pounds sterling: specify Set D. For general enquiries, and a free catalogue detailing other disk formats, precompiled fonts and lots of other goodies, contact: Eigen PD Software, P.O. Box 722, Swindon SN2 6YB (tel: 0793-611270) (JANET e-mail address: kellett@uk.ac.cran.rmcs) \subsection TeX for the Atari ST All enquiries for disks etc. should be directed to: The South West Software Library, P.O. Box 562, Wimborne, Dorset BH21 2YD (JANET e-mail address: mdryden@uk.co.compulink.cix) \section POSTAGE RATES All prices in Pounds Sterling. For Aston orders, make cheques payable to Aston University. 0.5" tapes: UK: 2.50 (one tape), 5.00 (two tapes). Europe: 5.00 (one tape), 9.00 (two tapes). Outside Europe please enquire. 8mm tapes: UK: 1.00, Europe: 2.00. Quarter-inch cartridges: UK: 1.00, Europe: 2.00. Diskettes: Quantity/Size Europe World UK 1st UK 2nd 18/3.5" 3.10 5.10 1.40 1.10 11/3.5" 1.80 2.90 0.80 0.65 18/5.25" 1.20 2.00 0.60 0.50 11/5.25" 0.80 1.30 0.50 0.35 \section POSTAL ADDRESSES Please include SELF-ADDRESSED ADHESIVE LABELS for return postage. Peter Abbott Information Systems, Aston University, Aston Triangle, Birmingham B4 7ET David Osborne Cripps Computing Centre, University of Nottingham, Nottingham NG7 2RD (for Quarter-inch cartridges ONLY -- must include stamps for return postage ) \section UK TeX USERS GROUP For details, contact: David Penfold, Edgerton Publishing Services, 30 Edgerton Road, Edgerton, Huddersfield HD3 3AD (tel: 0484 519462) or E McNeil-Sinclair, fax: 0272 236169 \bye End of UKTeX Digest [Volume 92 Issue 43] ****************************************