diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-04 14:16:50 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-04 14:16:50 +0000 |
commit | eb0ca0896a18ae41f243b3f096f2bb4737a8c2e2 (patch) | |
tree | e888952a01584e0e1baf628429a437922e6619cc /Master/texmf-dist/doc/plain/newsletr/quote.tex | |
parent | 846eb2662596380d270e987384a1c636441999c5 (diff) |
newsletr v01-016 22-Jan-2004
git-svn-id: svn://tug.org/texlive/trunk@9229 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/plain/newsletr/quote.tex')
-rwxr-xr-x | Master/texmf-dist/doc/plain/newsletr/quote.tex | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/plain/newsletr/quote.tex b/Master/texmf-dist/doc/plain/newsletr/quote.tex new file mode 100755 index 00000000000..79aa2a54300 --- /dev/null +++ b/Master/texmf-dist/doc/plain/newsletr/quote.tex @@ -0,0 +1,118 @@ +% +% File: QUOTE.TEX +% +% Author: Hunter Goatley +% goathunter@goatley.com +% +% Date: August 14, 1991 +% +% Abstract: +% +% This file defines the macros \begindoublequotes and \enddoublequotes, +% which let TeX replace the double-quote character (") with TeX's +% left double-quote and right double-quote. For example: +% +% "This is a test." ---> ``This is a test.'' +% +% The double-quote character is still available via \dq. (\" is still +% treated as the umlaut accent.) +% +% This macro makes a couple of assumptions about the double-quotes: +% +% 1. Double-quotes are assumed to come in pairs. When replacing +% double-quotes, the macro alternates between `` and ''. The only +% exception to this is noted in (2) below. +% 2. A double-quote at the beginning of a paragraph is always treated +% as ``. This correctly handles the case where a quotation is +% continued into a second paragraph: +% +% "This is the first paragraph.\par +% "This is the second paragraph of the same quote." +% +% Normal TeX spacing after `` and '' is maintained by saving and +% restoring the \spacefactor. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% HOW IT WORKS: +% +% The double-quote character (") is made active by \begindoublequotes. +% The " macro keeps track of left-quote/right-quote pairs and inserts +% the appropriate `` and '' in its place. +% +% Each character has a \spacefactor associated with it, which specifies +% the amount of stretch or shrink that a space following the character +% can have. Most characters have a factor of 1000, but some punctuation +% marks have higher spacefactors, most notably the period, which has a +% \spacefactor of 3000. This means the space following a period can +% stretch up to 3 times more than the space after a regular character, +% accounting for the increased space at the end of sentences. +% +% The `` and '' ligatures are assigned \spacefactor's of 0, so that the +% \spacefactor that is applied to the next character is the same as that +% of the character preceding the quotes. Because " has been redefined as +% a macro, any spaces following " are swallowed by TeX. It was necessary +% to have this macro re-insert any needed space so that the following +% cases worked correctly: +% +% "This is a test," she said. --> ``This is a test,'' she said. +% "This is in a list"; etc. --> ``This is in a list''; etc. +% +% Without the added space, the first example becomes: +% +% ``This is a test,''she said. +% +% The solution was to save the current \spacefactor before inserting a +% right double-quote, then resetting the \spacefactor after the +% insertion. The net effect was that the " macro has a \spacefactor +% of 0, which matches the way TeX treats `` and ''. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +{% % Begin a group for which " is active +\catcode`\"=\active % Make " an active character +\catcode`\@=11 % Make @ an active character +% +% \begindoublequotes +% +% This macro makes " an active character, resets the control sequence +% \dblqu@te to L (left), and defines \dq as a replacement for ". +% +\gdef\begindoublequotes{% % \begindoublequotes enables " + \global\catcode`\"=\active % Make " an active character + \global\chardef\dq=`\" % Double-quote char. via \dq + \global\let\dblqu@te=L % Always start with a left double-quote + } % End of macro +% +% Define the macro that will be executed whenever " is encountered. +% +\gdef"{% + % If the double-quote is the first character in a new paragraph, + % make sure it becomes a left double-quote. This case can be + % detected by checking to see if TeX is currently in vertical mode. + % If so, the double-quote is at the beginning of the paragraph + % (since " hasn't actually generated any horizontal mode tokens + % yet, TeX is still in vertical mode). If the mode is vertical, + % set \dblqu@te equal to L. + % + \ifinner\else\ifvmode\let\dblqu@te=L\fi\fi + % + % Now insert the appropriate left or right double-quote. + % + % If \dblqu@te is L, insert a `` and set \dblqu@te to R. + % + \if L\dblqu@te``\global\let\dblqu@te=R% + % + % Otherwise, save the current \spacefactor, insert '', set \dblqu@te + % to L, and reset the original \spacefactor. + % + \else + \let\xxx=\spacefactor % Save the \spacefactor + ''\global\let\dblqu@te=L% % Insert '' and reset \dblqu@te + \spacefactor\xxx % Reset the \spacefactor + \fi % End of \if L\dblqu@te... + } % End of " macro +} % End of group + +\gdef\enddoublequotes{% + \catcode`\"=12 %Set " back to other + } |