Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!umich!umeecs!msi-s0.msi.umn.edu!cs.umn.edu!ub.d.umn.edu!tchow From: tchow@ub.d.umn.edu (Timothy Chow) Newsgroups: comp.text.tex Subject: Re: looking for \everyline facilities Keywords: everyline, paragraph hacks Message-ID: <192@ub.d.umn.edu> Date: 10 Aug 90 01:30:03 GMT References: <2718@aipna.ed.ac.uk> Organization: None. This saves me from writing a disclaimer. Lines: 86 In article <2718@aipna.ed.ac.uk> sean@aipna.ed.ac.uk (Sean Matthews) writes: >What I want is a general facility for placing code at the >beginning, or end, of every line in a paragraph, in the same way >as I can place code at the beginning of every paragraph. It is probably impossible to meet this request, simply because of the way TeX works. Each situation has to be handled on its own. >2: for some styles of quotation (not in English) there are > running quotation marks down the side of the paragraph, as in > > `Statistics show that only 7.43 of 10 people who read this > `manual actually type the story.tex file as recommended, > `but that those people learn TeX best. So Why don't you > `join them.' In article duchier-denys@cs.yale.edu suggests the following solution: >\parindent=0pt >\newbox\foo \setbox\foo\hbox{`} >\everypar{\copy\foo} >\def\baz{\discretionary{}{\copy\foo\kern-3.33pt}{}% > \penalty10000 \hskip3.33pt plus1.66pt minus1.11pt} >\catcode`\^^M=13\let^^M=\baz\catcode`\ =13\let =\baz% >...... One problem with this solution is that it doesn't work right if some of the words in the text have to be hyphenated. One solution that avoids this drawback is the following. \newbox\quotebox \newcount\numlines \def\quote#1{ \setbox\quotebox=\vbox{\noindent\strut #1'\strut $$\global\numlines=\prevgraf$$} \setbox\quotebox=\vbox{\noindent\strut #1'\strut} \hbox to\hsize{\hss \vbox{\loop\ifnum\numlines>0\hbox{`}\advance\numlines by-1\repeat}% \box\quotebox}} \quote{Text of paragraph to be set in quotes should go here.} Here I have used ``hanging punctuation'' so that the left quotes stick out into the left margin. If you don't like this simply \advance \hsize by the width of \hbox{`} before creating \quotebox, and restore the value of \hsize afterwards. There are at least two drawbacks to my solution. The first is that the text of the quote is typeset twice, and this is inefficient. (This shouldn't be too hard to fix.) The second is that if the text to be quoted contains displayed equations or lines whose height or depth exceed that of a \strut, then the left quotes will not be placed properly. This is harder to fix, but in practice the problem will probably not arise too often. >1: for draft text, so that I can have (say) every fifth line > labeled with its number (as in play scripts), so that I can > indicate corrections and the like. A similar technique to the one above (but unfortunately with the same drawbacks) will work here. For simplicity I have numbered every line here, but a suitable \if construction can be incorporated so that only every fifth line will have a number next to it. \newbox\numberbox \newcount\numlines \newcount\linenum \linenum=0 \def\numberpar#1{ \setbox\numberbox=\vbox{\noindent\strut #1'\strut $$\global\numlines=\prevgraf$$} \setbox\numberbox=\vbox{\noindent\strut #1'\strut} \hbox to\hsize{\hss \vbox{\loop\ifnum\numlines>0\global\advance\linenum by1\hbox to.5in{\hfill$\scriptstyle\the\linenum$\ \ }\advance \numlines by-1\repeat}\box\numberbox}} \numberpar{Text of paragraph to be numbered here.} \numberpar{You can have as many paragraphs as you like.} -- Timothy Chow tchow@ub.d.umn.edu