summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/frankenstein/lips.sty
blob: 35b60029effd7f997782c57e01b93e2e92f5f1d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
%^^A* legal notices
% \iffalse
%
%   This program is part of the Frankenstein bundle for LaTeX.  
%
%   Copyright 1995-2001 Matt Swift <swift@alum.mit.edu>.
%
%   This file contains both the code and documentation for the
%   lips LaTeX package.  It will work ONLY if it is placed in a
%   proper directory.  Files called README, INSTALL, lips.tex
%   and lips.ins should have also been distributed to you
%   with this file.  See them for more information on how to typeset
%   the documentation with LaTeX and how to generate a version of this
%   file that will work faster than this one.
%
%   This program is free software; you may redistribute it and/or
%   modify it under the conditions of the LaTeX Project Public
%   License, either version 1.2 or (at your option) any later version.
%   The latest version of this license is in
%   http://www.latex-project.org/lppl.txt, and version 1.2 or later is
%   part of all distributions of LaTeX version 1999/12/01 or later.
%
%   This program is distributed in the hope that it will be useful,
%   but without any warranty; without even the implied warranty of
%   merchantability or fitness for a particular purpose.  See the
%   LaTeX Project Public License for more details.
%
% \fi  
%
%^^A* checks
%
%^^A NOTE:  The character table, with two %'s, will get written to all files.
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
% \CheckSum{207}
%
% \begin{abstract}
%   The \cs\lips command generates text ellipses that are closer to what
%   \manual suggests than what \cs\dots produces.  It does the right thing in
%   most circumstances, and so is easy to use.
% \end{abstract}
% \tableofcontents
%
% \part{Discussion}
%
% \section{Text Ellipses}
%
% \DescribeMacro{\lips}
% The macro \cs\lips should be used for all text ellipses, that is, ellipses
% not part of a mathematical expression.
%
% \manual does not acknowledge different spacings after different marks of
% punctuation, distinguish interword from intersentence space, or give rules
% about where to break a line near an ellipsis.  Given a context where such
% spaces do vary and rules for linebreaks can be given, I arrived at the
% following rules for handling them around ellipses.
% \begin{enumerate}
% \item Pre-, post-, and intra-ellipsis space is normal intra-word space, which
%       should be 3-to-em.  In \LaTeX{} there is also some glue (it's a 
%       ``rubber space'').
% \item When non-period punctuation $p$ follows \cs\lips, $p$ is followed by
%       the space that normally follows $p$.
% \item A period following \cs\lips is treated as if the period preceded
%       \cs\lips.  Conceptually, an ellipsis never precedes a period, so
%       conceptually there is only one case; but it is convenient to be able to
%       type either \code{\lips.} or \code{.\lips}.
% \item Lines are a tiny bit breakable before ellipses and a tiny bit
%       breakable after ellipses that are not followed by punctuation.
% \end{enumerate}
%
% In figure~\ref{fig:usage} are examples of correct usage and in
% figure~\ref{fig:comp} is a comparison of \cs\lips to \cs\dots.  You can
% substitute any of the characters \code$!"()*+,-/:;=?@[]'`|<>~{}$ for the
% exclamation point in the examples.  There can be additional contiguous spaces
% after \cs\lips, just like after any command name.  There can also be
% contiguous spaces before \cs\lips.
%
% \begin{figure}
% \DeleteShortVerb{\|}
% \begin{center}
% \begin{tabular}{lc}
% \bfseries source & \bfseries \hspace*{4em} result
% \end{tabular}\par\nobreak
% \par\nobreak
% \begin{tabular}{|lp{1in}|}
% \hline
% \verb*|Hello\lips. And|   & Hello\lips. And   \\\hline
% \verb*|Hello \lips. And|  & Hello \lips. And   \\\hline
% \verb*|Hello.\lips And|   & Hello.\lips And   \\\hline
% \verb*|Hello. \lips And|  & Hello. \lips And   \\\hline
% \verb*|one,\lips, three|  & one,\lips, three \\\hline
% \verb*|one, \lips, three| & one, \lips, three \\\hline
% \verb*|Hello\lips and|    & Hello\lips and    \\\hline
% \verb*|Hello \lips and|   & Hello \lips and    \\\hline
% \verb*|Hello!\lips And|   & Hello!\lips And   \\\hline
% \verb*|Hello! \lips And|  & Hello! \lips And   \\\hline
% \end{tabular}
% \end{center}
% \caption{\label{fig:usage}Examples of correct usage of \cs\lips.}
% \MakeShortVerb{\|}
% \end{figure}
%
% \begin{figure}
% \begin{center}
% \begin{tabular}{lc}
% \bfseries source & \bfseries \hspace*{4em} result
% \end{tabular}\par
% \par
% \DeleteShortVerb{\|}
% \begin{tabular}{|lp{1in}|}
% \hline
% \verb*|Hello\dots. And|   & Hello\dots. And   \\
% \verb*|Hello\lips. And|   & Hello\lips. And   \\\hline
% \verb*|Hello \dots. And|  & Hello \dots. And   \\
% \verb*|Hello \lips. And|  & Hello \lips. And   \\\hline
% \verb*|Hello.\dots And|   & Hello.\dots And   \\
% \verb*|Hello.\lips And|   & Hello.\lips And   \\\hline
% \verb*|Hello. \dots And|  & Hello. \dots And   \\
% \verb*|Hello. \lips And|  & Hello. \lips And   \\\hline
% \verb*|one,\dots, three|  & one,\dots, three  \\
% \verb*|one,\lips, three|  & one,\lips, three \\\hline
% \verb*|one, \dots, three| & one, \dots, three \\
% \verb*|one, \lips, three| & one, \lips, three \\\hline
% \verb*|Hello\dots and|    & Hello\dots and    \\
% \verb*|Hello\lips and|    & Hello\lips and    \\\hline
% \verb*|Hello \dots and|   & Hello \dots and    \\
% \verb*|Hello \lips and|   & Hello \lips and    \\\hline
% \verb*|Hello!\dots And|   & Hello!\dots And   \\
% \verb*|Hello!\lips And|   & Hello!\lips And   \\\hline
% \verb*|Hello! \dots And|  & Hello! \dots And   \\
% \verb*|Hello! \lips And|  & Hello! \lips And   \\\hline
% \end{tabular}
% \end{center}
% \caption{\label{fig:comp}Comparison of \cs\lips with \cs\dots.}
% \MakeShortVerb{\|}
% \end{figure}
% 
% \section{Line breaking considerations}
%
% \DescribeMacro\LPNobreakList
%   When \cs\lips is followed by certain punctuation (\code|,:;?!)']}/| by
%   default), we never want to break a line after the ellipsis and before that
%   punctuation.  For the other punctuation, such as open parenthesis and open
%   quote, we want normally breakable space following the ellipsis.
%   \cs\LPNobreakList is a list of those characters before which \cs\lips
%   should \emph{never} break a line.  To force unbreakable space following
%   \cs\lips, follow \cs\lips with a tie (|~|).
%
% \section{Limitations}
%
% \cs\lips does the right thing after \cname{par}, but after \cs\indent or
% \cs\noindent there is an extra preceding space (see the final section on
% testing for an example).  Suggestions on how to handle this problem are
% welcome.
%
% \StopEventually{}
%
% \part{Implementation}
%
% \section{Version control}
%
%  \begin{macro}{\fileinfo}
%  \begin{macro}{\DoXUsepackagE}
%  \begin{macro}{\HaveECitationS}
%  \begin{macro}{\fileversion}
%  \begin{macro}{\filedate}
%  \begin{macro}{\docdate}
%  \begin{macro}{\PPOptArg}
% These definitions must be the first ones in the file.
%    \begin{macrocode}
\def\fileinfo{Chicago Manual text ellipses (Frankenstein's lips)}
\def\DoXPackageS {}
\def\initelyHavECitationS {}
\def\fileversion{v2.1}
\def\filedate{2001/08/31}
\def\docdate{2001/08/31}
\edef\PPOptArg {%
  \filedate\space \fileversion\space \fileinfo
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% If we're loading this file from a \cs\ProcessDTXFile command (see the
% \package{compsci} package), then \cs\JusTLoaDInformatioN will be defined;
% othewise we assume it is not (that's why the FunkY NamE).
% 
% If we're loading from \cs\ProcessDTXFile, we want to load the packages listed
% in \cs\DoXPackageS (needed to typeset the documentation for this file) and
% then bail out.  Otherwise, we're using this file in a normal way as a
% package, so do nothing.  \cs\DoXPackageS, if there are any, are declared in
% the \ext{dtx} file, and, if you're reading the typeset documentation of this
% package, would appear just above.  (It's OK to call \cs\usepackage with an
% empty argument or \cs\relax, by the way.)
%    \begin{macrocode}
\makeatletter% A special comment to help create bst files.  Don't change!
\@ifundefined{JusTLoaDInformatioN} {%
  }{% ELSE (we know the compsci package is already loaded, too)
  \UndefineCS\JusTLoaDInformatioN
  \SaveDoXVarS
  \eExpand\csname DoXPackageS\endcsname\In {%use \csname in case it's undefined
    \usepackage{#1}%
  }%
  \RestoreDoXVarS
  \makeatother
  \endinput
}% A special comment to help create bst files.  Don't change!
%    \end{macrocode}
%
% Now we check for \LaTeX2e and declare the LaTeX package.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{lips}[\PPOptArg]
%    \end{macrocode}^^A special comment to help create bst files.  Don't change!
%
% ^^A NOTE: We have to compensate for the above backslashes, which are not
% ^^A       actually in the .dtx file the author works on, by adding to the
% ^^A       CheckSum.
%%
% \AddToCheckSum{17}^^A `dtx-update-checksum' automatically handles this.
% \AddToCheckSum{7}^^A The half a macrocode env. at the top is missed, however...
% \AddToCheckSum{10}^^A ... and so are the 5 \defs from the .dtx file 
%                   ^^A     that precede it.
% \IfCitations {%
%   \AddToCheckSum{2}^^A When \initelyHavECitationS is defined in
% }                  ^^A the .dtx file, we need 2 more in the CheckSum.
%
%
% \section{The macro}
%
% \begin{macro}{\Lips}
% \begin{macro}{\BracketedLips}
% \begin{macro}{\lips}
% \begin{macro}{\olips}
%   If we're in math mode, raise an error.  If we're in vertical mode, leave it
%   and do an ellipsis not breakable at the end.  If we're in horizontal mode,
%   call \cname{lp@lips@hmode}.
%
%   Normally I would use \cs\NewRobustCommand, but this seems not enough reason
%   to require the \package{moredefs} package.  We reserve the name \cs\lips by
%   hand.  In the future, this package may require \package{moredefs}.
%    \begin{macrocode}
\newcommand*\Lips {}
\let\Lips\relax
\DeclareRobustCommand\Lips {%
  \ifmmode
    \def\sc@t@a {%
      \PackageError{lips}
        {Don't use \protect\lips \space in math mode; use \protect\dots.}\@ehc
    }%
  \else
    \ifvmode
      \def\sc@t@a {%
        \leavevmode
        .\nobreak\ .\nobreak\ .\nobreak\ %
      }%
    \else
      \let\sc@t@a\lp@lips@hmode
    \fi
  \fi
  \sc@t@a
}
\newcommand*\BracketedLips {}
\let\BracketedLips\relax
\DeclareRobustCommand\BracketedLips {%
  \ifmmode
    \def\sc@t@a {%
      \PackageError{lips}
        {Don't use \protect\lips \space in math mode; use \protect\dots.}\@ehc
    }%
  \else
    \ifvmode
      \def\sc@t@a {%
        \leavevmode
        [.\nobreak\ .\nobreak\ .]\nobreak\ %
      }%
    \else
      \let\sc@t@a\lp@blips@hmode
    \fi
  \fi
  \sc@t@a
}
%    \end{macrocode}
% \todo{need the relax to avoid mistaking as optarg in some
% contexts?}  In MLA style, that is, with the \option{mla} option, \cs\lips
% gives you brackets, meaning you To get no brackets, use \cs\olips for
% ``original lips,'' that is, ellipses in the original document.  \todo{Better
% dox here.  Are options case sensitive?  If so, make MLA=mla.}
%    \begin{macrocode}
\newlet\lips\Lips
\newlet\olips\lips
\DeclareOption{mla} {%
  \let\lips\BracketedLips
}
\ProcessOptions
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lp@lips@hmode}
% \begin{macro}{\lp@blips@hmode}
% \begin{macro}{\GobbleIgnoreSpaces}
%   The horizontal mode case.  Then we remove the last skip on the horizontal
%   list.  If the next character is a period, we want to act as if the period
%   preceded \cs\lips, so we plonk down a period, a minimally-breakable space,
%   then an ellipsis ending with normally-breakable space.  This keeps the
%   ellipsis on the same line as the sentence it follows if at all possible,
%   but allows it to spill onto the next line if there's no other way to avoid
%   an overfull line.  Then we want to gobble up the period that's about to
%   come, and ignore any spaces after it, since we've already inserted proper
%   space.
%
%   If the next character is not a period, we output a minimally-breakable
%   space and an ellipsis.  To decide whether to follow it with unbreakable or
%   normally-breakable space, we need to know more about the next character
%   than just that it is not a period, so we \cs\let it to scratch |a| and call
%   \cname{lp@lips@check@punct}.
%
% \todo{document different logic with bracketed lips; how the heck to handle
% greater inter-sentence space?}
%    \begin{macrocode}
\newcommand\lp@lips@hmode {%
  \unskip
  \@ifnextchar . {%
      .\penalty9999\ .\nobreak\ .\nobreak\ .\ %
      \GobbleIgnoreSpaces
    }{% ELSE
    \penalty9999\ .\nobreak\ .\nobreak\ .%
    \futurelet\sc@t@a\lp@lips@check@punct
  }%
}
% hmm, have to keep the check for period i guess because i don't want it in
% nobreaklist?  because the break/nobreak is different?  because it's more efficient?
\newcommand\lp@blips@hmode {%
  \unskip
  \@ifnextchar . {%
      \penalty9999\ [.\nobreak\ .\nobreak\ .]%
    }{% ELSE
    \penalty9999\ [.\nobreak\ .\nobreak\ .]%
    \futurelet\sc@t@a\lp@lips@check@punct
  }%
}
\newcommand\GobbleIgnoreSpaces [1] {%
  \ignorespaces
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\LPNobreakList}
% \begin{macro}{\lp@<punctuation>}
%   We'd like to use \code{\ifcat.\sc@t@a} for this, but that won't work when
%   we get a command sequence in scratch |a|.  Bummer.
%   Do I really need to define all this punctuation now?  It protects against
%   something becoming an active char or otherwise changing catcodes after the
%   \package{lips} package is loaded.
%    \begin{macrocode}
\newcommand*\lp@bang {}
\newcommand*\lp@rparen {}
\newcommand*\lp@comma {}
\newcommand*\lp@slash {}
\newcommand*\lp@colon {}
\newcommand*\lp@semic {}
\newcommand*\lp@q {}
\newcommand*\lp@rbrack {}
\newcommand*\lp@rquote {}
\newcommand*\lp@tilde {}

\let\lp@bang=!
\let\lp@rparen=)
\let\lp@comma=,
\let\lp@slash=/
\let\lp@colon=:
\let\lp@semic=;
\let\lp@q=?
\let\lp@rbrack=]
\let\lp@rquote='
\let\lp@tilde=~

% \egroup

%    \end{macrocode}
% I'm making an attempt to put these in order of expected frequency.  A
% doublequote could be at the beginning or end of a quotation, so half the time
% you'll have to correct by adding |{}|, so let's leave it out
% so there's one less to check.
%    \begin{macrocode}
\newcommand \LPNobreakList {%
  \lp@comma \lp@colon  \lp@semic
  \lp@q \lp@bang 
  \lp@rparen \lp@rquote \lp@rbrack \egroup
  \lp@slash
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lp@lips@check@punct}
%   Add nonbreakable space if scratch |a| is in \cs\LPNobreakList; add
%   normally-breakable space otherwise.  Add no space at all if scratch |a| is
%   a tie---the tie will add nonbreakable space. We use just the guts of
%   \cname{@tfor} for efficiency.
%    \begin{macrocode}
\newcommand\lp@lips@check@punct {%
  \ifx\sc@t@a\lp@tilde
  \else
    \@tempswatrue
    \let\@fortmp\PunctList
    \expandafter\@tforloop\LPNobreakList\@nil\@nil\@@\reserved@a {%
      \ifx\sc@t@a\reserved@a
	\@tempswafalse
	\@break@tfor
      \fi
     }%
    \if@tempswa
      \ %
    \else
      \nobreak\ %
    \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% You might want to compare the \LaTeX{} version (as of 95/12/01).
% \cname{fontdimen3} is the interword stretchability, not interword space.
% \begin{codeexample}
% \DeclareTextCommandDefault{\textellipsis}{%
%   .\kern\fontdimen3\font
%   .\kern\fontdimen3\font
%   .\kern\fontdimen3\font
% }
% \def\mathellipsis{\mathinner{\ldotp\ldotp\ldotp}}
% \DeclareRobustCommand{\dots}{%
%   \ifmmode\mathellipsis\else\textellipsis\fi
% }
% \let\ldots\dots
% \end{codeexample}
%
% \part{Testing}
%
% \section{Ante-\cs\lips}
%
% This is some testing.  We need some text here as the first paragraph after
% the \cs\section.
%
% : \lips.
%
% : \lips text.
%
% : \lips)
%
% ; \lips.
%
% ; \lips text.
%
% ; \lips)
%
% ! \lips.
%
% ! \lips text.
%
% ! \lips)
%
% t \lips.
%
% t \lips text.
%
% t \lips)
%
% T \lips.
%
% T \lips text.
%
% T \lips)
%
% , \lips.
%
% , \lips text.
%
% , \lips)
%
%  \par \lips and (|\par \lips and|)
%  \par and (|\par and|)
%
%  \par\indent \lips (|\par\indent \lips and|)
%  \par\indent and (|\par\indent and|)
%
%  \par\noindent \lips and (|\par\noindent \lips and|)
%  \par\noindent and (|\par\noindent and|)
%
%  \par And.\lips \par (|And.\lips \par|)
%  \par And. \par (|And. \par|)
%
% \section{Post-\cs\lips}
%
%  \cs\lips before a tie: One two three.\lips~tiedtolips (I doubt you'd want to
%  do this.)
%
%  \cs\lips before ), e.g., punctuation transparent to spacefactors:
%
%  (One two three.\lips)\ This follows the ) with interword space, to compare.
%
%  (One two three.\lips) This should follow the ) with intersentence space.
%
%  (One two three.\lips\@) This should follow the ) with intersentence space.
%
% \cs\lips before shortverb: \lips |shortverb verbatim stuff|
%
% \cs\lips before \cs\textsf: \lips \textsf{sansserif}
%
% \begin{center}
% \cs\lips before |\\|: \lips \\
% second line of a \env{center} environment
% \end{center}
%
% \cs\lips before \cs\#: \lips \#
%
% \cs\lips before |<|: \lips <
%
% \cs\lips before an abbrev: \lips \Frankenstein
%
% \cs\lips before \cs\cite: \lips \cite{chicago:14}
%
% \cs\lips before |$|: \lips $f=ma$            ^^A$
%
%^^A \cs\lips in math mode (error!): $\lips^2$
%
% \begin{tabular}{ll}
% \cs\lips before |&|: \lips & second column of a \env{tabular}
% \end{tabular}
%
% \Finale