summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/contour/contour.dtx
blob: 68fe993e06cd21c2e60780e919883c3d7e8e0526 (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
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
% \iffalse meta comment
% File: contour.dtx Copyright (C) 1999--2004 Harald Harders, Morten Høgholm
% \fi
%
% \iffalse
%
%<*driver>
\documentclass{ltxdoc}
\IfFileExists{contour.sty}{\usepackage{contour}
  \let\contourSTYfound\active}{\GenericWarning{contour.dtx}{Package
    file contour.sty not found (Documentation will be messed up!^^J^^A
    Generate contour.sty by (La)TeXing contour.ins, process
    contour.dtx again)^^J}\stop}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{url}
\GetFileInfo{contour.sty}
\title{The contour package}
\author{Harald Harders (\texttt{h.harders@tu-bs.de})\\
  Morten H\o gholm (\texttt{moho01ab@student.cbs.dk})}
\date{File version \fileversion, date \filedate, printed \today}
\EnableCrossrefs
\CodelineIndex
\DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
\DoNotIndex{\setcounter,\space,\ifx,\else,\fi,\global,\newlength,\number}
\DoNotIndex{\relax,\setlength,\strip@pt,\the,\typeout,\p@,\z@,\@ne}
\DoNotIndex{\ProvidesPackage,\RequirePackage,\NeedsTeXFormat}
\DoNotIndex{\@firstoftwo,\@secondoftwo,\ifdim,\fi,\ifnum,\fi}
\CodelineNumbered
\RecordChanges
\CheckSum{326}
\renewcommand\floatpagefraction{0.75}
\begin{document}
 \DocInput{contour.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{2.14}{2004/11/18}{Full outline support for Y\&Y DVIPSONE}%
% \changes{2.12}{2004/08/28}{Full outline support for V\TeX}%
% \changes{2.11}{2004/08/28}{Restricted outline support for V\TeX}%
% \changes{2.10}{2004/08/23}{Print text with real outlines for vector
%   fonts}%
% \changes{2.00}{2004/08/03}{Allow arbitrary numbers of text copies}%
% \changes{1.04}{2003/11/09}{Avoide usage of \cs{textversion} etc.}%
%
% \maketitle
% \begin{abstract}
% \noindent
% This package generates a colored contour around a given text in order 
% to enable printing text over a background without the need of a 
% color box around the text.
% By default this is done by placing copies of the text around the text
% itself and can be switched to use real outlines if supported by the
% backend driver.
% \end{abstract}
%
% \tableofcontents
%
% \section*{Copyright}
% Copyright  1999--2004 Harald Harders, Morten H\o gholm.
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
% \section{Introduction}
% Sometimes it is necessary to print text over a background that is
% not pure white, e.g., in gnuplot plots. It is not always wished to
% plot the text in a rectangular box since this can cover important
% information or look poor. This package provides a solution to cover
% less space with the text and ensure readable text in the same time.
%
% The used technique is quite simple.
% By default, in a circle around the original text position the same
% text is printed evenly distributed 16, 32, or a a given number
% times.
% The default radius for the circle is $0.03\,\mathrm{em}$.
% If requested and supported by the used driver (dvips, pdf\TeX, V\TeX,
% DVIPSONE) a real outline can be chosen instead of text copies.
%
%
% \section{User interface}
%
% To use this package place
% \begin{verbatim}
%\usepackage[<options>]{contour}\end{verbatim}
% in the preamble of your document.
%
% If loaded without package option or with the option |copies| the
% contour is printed by placing copies of the text around the original
% text, as described below.
% This can be changed by the option |outline|.
% If specified this option the contour is printed by a real outline of
% the text instead of copies.
% This increases speed as well as quality\footnote{Especially in
% Acrobat Reader, the quality is better.} and reduces the file size.
% But some prerequisites have to be fulfilled:
% \begin{itemize}
% \item The backend driver has to be supported.
%   Currently, dvips, pdf\TeX, V\TeX, and DVIPSONE are supported.
%   Normally, the file |contour.cfg| tries to find out which driver
%   has to be loaded.\footnote{DVIPSONE cannot be determined
%     automatically.}
%   But you can also specify the driver by giving one of the package
%   options |dvips|, |xdvi|, |pdftex|, |vtex|, or |dvipsone|.
%   |xdvi| refers to |dvips| as driver.
%   In xdvi and DVIWindo, the contours are silently ignored.
% \item Outline (vector) fonts have to be used.
%   With dvips, this means that Type\,1 fonts have to be used.
%   With pdf\TeX, Type\,1 or TrueType fonts are supported.
%   If you are using METAFONT fonts you have to use copies (package
%   option |copies|).
% \end{itemize}
%
%
% \DescribeMacro{\contour}%
% The package provides the commands
%\begin{verbatim}
%\contour{<color>}{<text>}
%\contour[<number>]{<color>}{<text>}
%\contour*{<color>}{<text>}\end{verbatim}
% which produce the text \meta{text} with a \meta{color}ed contour
% around.
% The text itself is typeset in the normal active color.
% The normal \cs{contour} command produces 16 copies of the text while
% the |*| variant makes 32 copies.
% If \meta{number} is given, the given number of copies is generated
% around the text.
% If \meta{number} is |auto| instead of a number, the number of copies
% is calculated automatically depending on the font size.
%
% \DescribeMacro{\contourlength}%
% The radius of the circle (= thickness of the contour) can be changed using
% the command \cs{contourlength}\marg{length}, where \meta{length} is a
% length understood by \LaTeX. The length is not expanded when defining the
% contour length but when using it. For example when using |0.05em|, 
% $0.05\,\mathrm{em}$ of the font used in the command \cs{contour} are used.
%
% \DescribeMacro{\contournumber}%
% By default, \cs{contour} generates 16 copies of the text.
% You can change this by using \cs{contournumber}, e.g.,
%\begin{verbatim}
%\contournumber{27}\end{verbatim}
% If you specify |auto| instead of a number, \cs{contour} will use the
% automatically calculated number of copies.
% You may also use the package option |auto| to reach this behaviour:
% \begin{verbatim}
%\usepackage[auto]{contour}\end{verbatim}
% If using outlines the number of copies is ignored.
%
%
% \section{Examples}
%
% The command
%\begin{verbatim}
% \colorbox{black}{This text is not visible
%   \contour{white}{but this is.}}\end{verbatim}
% produces:
% \medskip
%
% \noindent
% \colorbox{black}{This text is not visible \contour{white}{but this
% is.}}
% \medskip
%
% Another example is shown in Figure~\ref{fig:comparison}.
% \begin{figure}
% \contourlength{0.05em}
% \centering
% \unitlength1mm
% \begin{picture}(50,30)%
% \put(0,0){\line(1,0){50}}%
% \put(0,30){\line(1,0){50}}%
% \put(0,0){\line(0,1){30}}%
% \put(50,0){\line(0,1){30}}%
% \put(0,25){\line(1,1){5}}%
% \put(0,20){\line(1,1){10}}%
% \put(0,15){\line(1,1){15}}%
% \put(0,10){\line(1,1){20}}%
% \put(0,5){\line(1,1){25}}%
% \multiput(0,0)(5,0){5}{\line(1,1){30}}%
% \put(25,0){\line(1,1){25}}%
% \put(30,0){\line(1,1){20}}%
% \put(35,0){\line(1,1){15}}%
% \put(40,0){\line(1,1){10}}%
% \put(45,0){\line(1,1){5}}%
% \put(0,5){\line(1,-1){5}}%
% \put(0,10){\line(1,-1){10}}%
% \put(0,15){\line(1,-1){15}}%
% \put(0,20){\line(1,-1){20}}%
% \put(0,25){\line(1,-1){25}}%
% \multiput(0,30)(5,0){5}{\line(1,-1){30}}%
% \put(25,30){\line(1,-1){25}}%
% \put(30,30){\line(1,-1){20}}%
% \put(35,30){\line(1,-1){15}}%
% \put(40,30){\line(1,-1){10}}%
% \put(45,30){\line(1,-1){5}}%
% \put(25,23){\makebox(0,0)%
%   {{\Large\colorbox{white}{text with colorbox}}}}%
% \put(25,15){\makebox(0,0)%
%   {{\Large\contour{white}{text with contour}}}}%
% \put(25,7){\makebox(0,0)%
%   {{\Large simple text}}}%
% \end{picture}
% \caption{Comparison of the commands \cs{colorbox} and
% \cs{contour}}
% \label{fig:comparison}
% \end{figure}
%
% In Figure~\ref{fig:anzahl}, you can see how the output depends on
% the number of copies.
% \begin{figure}
% \centering
% \begin{minipage}{0.85\linewidth}
% \contourlength{0.08em}%
% \let\lw\linewidth
% \definecolor{gray50}{rgb}{0.5,0.5,0.5}
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[1]{white}{Test}}}}\\%
% a) 1 white copy
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[2]{white}{Test}}}}\\%
% b) 2 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[3]{white}{Test}}}}\\%
% c) 3 white copies
% \end{minipage}\\[5pt]
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[4]{white}{Test}}}}\\%
% e) 4 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[8]{white}{Test}}}}\\%
% f) 8 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[16]{white}{Test}}}}\\%
% g) 16 white copies
% \end{minipage}\\[5pt]
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[32]{white}{Test}}}}\\%
% h) 32 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[60]{white}{Test}}}}\\%
% i) 60 white copies
% \end{minipage}
% \hfill
% \begin{minipage}{0.3\lw}
% \resizebox{\lw}{!}{\colorbox{gray50}{{\Huge\contour[120]{white}{Test}}}}\\%
% j) 120 white copies
% \end{minipage}
% \end{minipage}
% \caption{Contours with different numbers of copies
% with a large distance between text and copies}
% \label{fig:anzahl}
% \end{figure}
%
%
% \section{Advanced internals}
%
% Normally, it is not planned to switch between outline and copy mode.
% If you really have to do it you can use the boolean
% \cs{ifcon@outline}.
% \cs{con@outlinetrue} switches on outlines, while replacing |true| by
% |false| switches them off.
% Don't forgett to surround it by \cs{makeatletter} and
% \cs{makeatother} to allow |@| in command names.
%
% See the difference between copy and outline mode:
% \medskip
%
% \begingroup
% \contourlength{0.05em}%
% \Huge
% \textcolor{white}{\contour{black}{Copies}}
% \makeatletter
% \con@outlinetrue
% \makeatother
% \textcolor{white}{\contour{black}{Outline}}
% \endgroup
% 
%
% \section{Acknowledgements}
%
% Thanks to Richard Pfeiffer who had the idea for this package and
% wrote some code that did it.
%
% Thanks to Dietrich Grau who asked me for support of DVIPSONE and who
% did the testing of all my code ideas for this driver since I do not
% have Y\&Y \TeX.
%
%
% \StopEventually{\PrintChanges \PrintIndex}
%
%
% \section{The implementation}
%
% Heading of the package:
%    \begin{macrocode}
%<package>\NeedsTeXFormat{LaTeX2e}
%<dvips>\ProvidesFile{dvips.cnt}
%<pdftex>\ProvidesFile{pdftex.cnt}
%<vtex>\ProvidesFile{vtex.cnt}
%<dvipsone>\ProvidesFile{dvipsone.cnt}
%<cfgfile>\ProvidesFile{contour.cfg}
%<package>\ProvidesPackage{contour}
%<package|drv|cfgfile>  [2004/11/18  v2.14  Print contoured text (HH, MH)]
%<*package>
%    \end{macrocode}
%
% \subsection{The package}
%
% This package requires the color package from the graphics bundle:
%    \begin{macrocode}
\RequirePackage{color}
%    \end{macrocode}
% This package requires the trig package:
%    \begin{macrocode}
\RequirePackage{trig}
%    \end{macrocode}
% A command that makes \cs{color} inactive prevent the background text
% color from being changed:
% \changes{2.10}{2004/08/23}{Bugfix: enable switching colors inside
%   \cs{contour} argument}%
%    \begin{macrocode}
\def\con@coloroff{%
  \def\@undeclaredcolor[##1]##2{}%
  \def\@declaredcolor##1{}%
}
%    \end{macrocode}
% Set text to a specified relative position without using space:
%    \begin{macrocode}
\newcommand*\con@put[3]{%
  \rlap{\hskip#1\raisebox{#2}[0pt]{#3}}%
}
%    \end{macrocode}
% \begin{macro}{\contourlength}
% Define the commands for changing the base length:
%    \begin{macrocode}
\newcommand*\contourlength[1]{\def\con@base@length{#1}}
\contourlength{0.03em}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\contournumber}
% Define the commands for changing the number of text copies:
%    \begin{macrocode}
\newcommand*\contournumber[1]{\def\con@default@copies{#1}}
\contournumber{16}
%    \end{macrocode}
% \end{macro}
% Define new offset length:
%    \begin{macrocode}
\newlength{\con@length}
%    \end{macrocode}
% Define the angles for using `\meta{\#1}' copies unless they've
% previously been defined. We use `trig' for this.
%    \begin{macrocode}
\newcommand*\con@define@copyangles[1]{%
  \edef\con@tempa{auto}%
  \edef\con@tempb{#1}%
%    \end{macrocode}
% Set the number of copies automatically.
%    \begin{macrocode}
  \ifx\con@tempa\con@tempb
    \expandafter\ifdim\f@size pt<15pt\relax
      \edef\con@tempb{16}%
    \else
      \expandafter\ifdim\f@size pt<25pt\relax
        \edef\con@tempb{32}%
      \else
        \expandafter\ifdim\f@size pt<50pt\relax
          \edef\con@tempb{60}%
        \else
          \edef\con@tempb{120}%
        \fi
      \fi
    \fi
  \fi
  \@tempcnta=\con@tempb\relax
  \@ifundefined{con@\number\@tempcnta @copies}{%
    \global\@namedef{con@\number\@tempcnta @copies}{}%
    \@tempdima=360\p@
    \divide\@tempdima by \@tempcnta
    \@tempdimb=\z@
    \@tempcntb=\z@
    \loop
      \ifnum\@tempcntb<\@tempcnta
        \edef\con@temp@fdim{\strip@pt\@tempdimb}%
        \CalculateSin{\con@temp@fdim}%
        \CalculateCos{\con@temp@fdim}%
        \advance\@tempcntb \@ne
        \advance\@tempdimb \@tempdima\relax
    \repeat
  }{}%
  \let\con@tempa\@undefined
  \let\con@tempb\@undefined
}
%    \end{macrocode}
% \begin{macro}{\contour}
% The starred version of \cs{contour} prints 32 copies.
%    \begin{macrocode}
\newcommand*\contour{\@ifstar{\@contour[32]}{\@contour}}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*\@contour[3][\con@default@copies]{%
  \ifvmode
    \leavevmode
  \fi
  \setlength\con@length{\con@base@length}%
%    \end{macrocode}
% Print outline or copies?
%    \begin{macrocode}
  \ifcon@outline
    \typeout{contour: Using real outline for `#3'\on@line.}%
    \@contour@outline{#2}{#3}%
  \else
    \begingroup
%    \end{macrocode}
% Calculate the copy angles.
%    \begin{macrocode}
      \con@define@copyangles{#1}%
      \typeout{contour: Using \the\@tempcnta\space copies for `#3'\on@line.}%
      \@tempdima=360\p@
      \divide\@tempdima by \@tempcnta\relax
      \@tempdimb=\z@
      \@tempcntb=\z@
%    \end{macrocode}
% Set color ans switch off color command inside argument.
%    \begin{macrocode}
      \color{#2}%
      \con@coloroff
%    \end{macrocode}
% Print the copies.
%    \begin{macrocode}
      \loop
        \ifnum\@tempcntb<\@tempcnta\relax
          \edef\con@temp@fdim{\strip@pt\@tempdimb}%
          \con@put
            {\UseSin{\con@temp@fdim}\con@length}%
            {\UseCos{\con@temp@fdim}\con@length}%
            {#3}%
          \advance\@tempcntb \@ne\relax
          \advance\@tempdimb\@tempdima\relax
      \repeat
    \endgroup
%    \end{macrocode}
% Print the main text.
%    \begin{macrocode}
    \mbox{#3}%
  \fi
}
%    \end{macrocode}
% By default, no driver is active.
%    \begin{macrocode}
\providecommand*\con@driver{\@empty}
%    \end{macrocode}
% Boolean for using outline or copies.
%    \begin{macrocode}
\newif\ifcon@outline
%    \end{macrocode}
% Options:
%    \begin{macrocode}
\DeclareOption{auto}{\contournumber{auto}}
\DeclareOption{dvips}{\def\con@driver{dvips.cnt}}
\DeclareOption{xdvi}{\ExecuteOptions{dvips}}
\DeclareOption{pdftex}{\def\con@driver{pdftex.cnt}}
\DeclareOption{vtex}{\def\con@driver{vtex.cnt}}
\DeclareOption{dvipsone}{\def\con@driver{dvipsone.cnt}}
\DeclareOption{outline}{\con@outlinetrue}
\DeclareOption{copies}{\con@outlinefalse}
%    \end{macrocode}
% Load configuration file if existing.
%    \begin{macrocode}
\InputIfFileExists{contour.cfg}{%
  \typeout{Loading configuration file `contour.cfg'.}%
}{%
  \typeout{No configuration file `contour.cfg' found.}%
}
%    \end{macrocode}
% Process the options.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
% Load the driver file.
%    \begin{macrocode}
\expandafter\ifx\con@driver\@empty
  \ifcon@outline
    \PackageError{contour}{Chosen package option `outline' but no
      driver defined}{Leave out the `outline' option or define a driver}%
  \else
    \PackageWarning{contour}{No driver defined (which does not matter
      when using copies)}%
  \fi
\else
  \InputIfFileExists{\con@driver}{%
    \typeout{contour: Using driver file `\con@driver'.}%
  }{%
    \PackageError{contour}{Driver file `\con@driver' does not exist}{}%
  }%
\fi
%</package>
%    \end{macrocode}
% \end{macro}
%
% \subsection{Driver Files}
%
% \subsubsection{Dvips}
%
% \begin{macro}{\@contour@outline}
% Prints the text and contour using real outlines.
% \cs{@contour@outline\marg{color}\marg{text}}
%    \begin{macrocode}
%<*dvips>
\newcommand*\@contour@outline[2]{%
  \begingroup
%    \end{macrocode}
% Double the width of the contour since the inner half is overprinted
% by the normal text; convert |pt| to |bp|.
%    \begin{macrocode}
    \setlength\con@length{2\con@length}%
    \setlength\con@length{0.99626400996\con@length}%
%    \end{macrocode}
% Set the contour color and disable color command.
%    \begin{macrocode}
    \color{#1}%
    \con@coloroff 
%    \end{macrocode}
% PostScript preamble to print an outline for the text.
%    \begin{macrocode}
    \special{ps:
%    \end{macrocode}
% First, save all graphics settings to avoid side effects.
%    \begin{macrocode}
      gsave
%    \end{macrocode}
% Start a new path and choose a round pen.
%    \begin{macrocode}
        newpath
        1 setlinejoin
        1 setlinecap
%    \end{macrocode}
% Set the line width and scale it according to the PostScript scale.
%    \begin{macrocode}
        Resolution 72 div DVImag mul
        \strip@pt\con@length\space mul setlinewidth
%    \end{macrocode}
% \changes{2.13}{2004/11/04}{More robust mechanism to change
%   Postscript internals for dvips}%
% Save |show| to be able to restore it later.
%    \begin{macrocode}
        /cntorigshow /show load def
%    \end{macrocode}
% Redefine the |show| command that prints a text to do the outline
% instead of the text.
%    \begin{macrocode}
        /show { false charpath } def
    }%
%    \end{macrocode}
% Typeset the outline text.
%    \begin{macrocode}
    \rlap{#2}%
%    \end{macrocode}
% PostScript postamble.
%    \begin{macrocode}
    \special{ps:
%    \end{macrocode}
% Finally, do the outline.
%    \begin{macrocode}
        stroke
%    \end{macrocode}
% Restore the original settings.
%    \begin{macrocode}
        /show /cntorigshow load def
      grestore
    }%
  \endgroup
%    \end{macrocode}
% Print the main text.
%    \begin{macrocode}
  \mbox{#2}%
}
%</dvips>
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{pdf\TeX}
%
% \begin{macro}{\@contour@outline}
% Prints the text and contour using real outlines.
% \cs{@contour@outline\marg{color}\marg{text}}
%    \begin{macrocode}
%<*pdftex>
\newcommand*\@contour@outline[2]{%
  \begingroup
%    \end{macrocode}
% Double the width of the contour since the inner half is overprinted
% by the normal text; convert |pt| to |bp|.
%    \begin{macrocode}
    \setlength\con@length{2\con@length}%
    \setlength\con@length{0.99626400996\con@length}%
%    \end{macrocode}
% Set the contour color and disable color command.
%    \begin{macrocode}
    \color{#1}%
    \con@coloroff 
%    \end{macrocode}
% PDF preamble.
%    \begin{macrocode}
    \pdfliteral{%
%    \end{macrocode}
% Save the graphics settings.
%    \begin{macrocode}
      q
%    \end{macrocode}
% Choose a round pen.
%    \begin{macrocode}
      1 j
      1 J
%    \end{macrocode}
% Switch text to print an outline instead of fill.
%    \begin{macrocode}
      1 Tr
%    \end{macrocode}
% Set the line width.
%    \begin{macrocode}
      \strip@pt\con@length\space w
    }%
%    \end{macrocode}
% Typeset the outline text.
%    \begin{macrocode}
    \rlap{#2}%
%    \end{macrocode}
% PDF postamble.
%    \begin{macrocode}
    \pdfliteral{%
%    \end{macrocode}
% Restore original settings.
%    \begin{macrocode}
      Q
    }%
  \endgroup
%    \end{macrocode}
% Print the main text.
%    \begin{macrocode}
  \mbox{#2}%
}
%</pdftex>
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{V\TeX}
%
% \begin{macro}{\@contour@outline}
% Prints the text and contour using real outlines.
% \cs{@contour@outline\marg{color}\marg{text}}
%    \begin{macrocode}
%<*vtex>
\newcommand*\@contour@outline[2]{%
  \begingroup
%    \end{macrocode}
% Double the width of the contour since the inner half is overprinted
% by the normal text; convert |pt| to |bp|.
%    \begin{macrocode}
    \setlength\con@length{2\con@length}%
    \setlength\con@length{0.99626400996\con@length}%
%    \end{macrocode}
% Set the contour color and disable color command.
%    \begin{macrocode}
    \color{#1}%
    \con@coloroff 
%    \end{macrocode}
% PostScript preamble to print an outline for the text.
%
% At this point, V\TeX\ does an ugly job since it interprets this code
% immediately and thus puts the path itself into the output instead of
% just let the printer do the work.
% I do not know how to change this.
%    \begin{macrocode}
    \special{pS:
%    \end{macrocode}
% First, save all graphics settings to avoid side effects.
%    \begin{macrocode}
      save
%    \end{macrocode}
% Start a new path and choose a round pen.
%    \begin{macrocode}
        newpath
        1 setlinejoin
        1 setlinecap
%    \end{macrocode}
% Set the line width.
%    \begin{macrocode}
        \strip@pt\con@length\space setlinewidth
%    \end{macrocode}
% Redefine the command that prints a text to do the outline instead of
% the text.
%    \begin{macrocode}
        /show { false charpath } def
    }%
%    \end{macrocode}
% Typeset the outline text.
%    \begin{macrocode}
    \rlap{#2}%
%    \end{macrocode}
% PostScript postamble.
%    \begin{macrocode}
    \special{pS:
%    \end{macrocode}
% Finally, do the outline.
%    \begin{macrocode}
        stroke
%    \end{macrocode}
% Restore the original settings.
%    \begin{macrocode}
      restore
    }%
  \endgroup
%    \end{macrocode}
% Print the main text.
%    \begin{macrocode}
  \mbox{#2}%
}
%</vtex>
%    \end{macrocode}
% \end{macro}
%
%
% \subsubsection{DVIPSONE}
% \changes{2.14}{2004/11/05}{Add support for DVIPSONE}%
%
% \begin{macro}{\@contour@outline}
% Prints the text and contour using real outlines.
% \cs{@contour@outline\marg{color}\marg{text}}
%    \begin{macrocode}
%<*dvipsone>
\newcommand*\@contour@outline[2]{%
%    \end{macrocode}
% First, print the text.
% This is a hack and avoids problems when \cs{contour} is used in some
% contexts, e.g., at the begin of the text.
%    \begin{macrocode}
  \rlap{#2}%
  \begingroup
%    \end{macrocode}
% Double the width of the contour since the inner half is overprinted
% by the normal text; convert |pt| to |bp|.
%    \begin{macrocode}
    \setlength\con@length{2\con@length}%
    \setlength\con@length{0.99626400996\con@length}%
%    \end{macrocode}
% Set the contour color and disable color command.
%    \begin{macrocode}
    \color{#1}%
    \con@coloroff 
%    \end{macrocode}
% PostScript preamble to print an outline for the text.
%    \begin{macrocode}
    \special{ps:
%    \end{macrocode}
% First, save all graphics settings to avoid side effects.
%    \begin{macrocode}
      gsave
%    \end{macrocode}
% Save the current position to be used for the new path.
%    \begin{macrocode}
        currentpoint
%    \end{macrocode}
% Start a new path and go back to the old position.
%    \begin{macrocode}
        newpath
        moveto
%    \end{macrocode}
% Choose a round pen.
%    \begin{macrocode}
        1 setlinejoin
        1 setlinecap
%    \end{macrocode}
% Set the line width and scale it according to the PostScript scale.
% The factor 65693.4 is chosen by trial and error and may be inexact.
%    \begin{macrocode}
        65693.4 \strip@pt\con@length\space mul setlinewidth
%    \end{macrocode}
% Save |show| to be able to restore it later.
%    \begin{macrocode}
        /cntorigshow /show load def
%    \end{macrocode}
% Redefine the |show| command that prints a text to do the outline
% instead of the text.
%    \begin{macrocode}
        /show { false charpath } def
    }%
%    \end{macrocode}
% Typeset the outline text.
%    \begin{macrocode}
    \rlap{#2}%
%    \end{macrocode}
% PostScript postamble.
%    \begin{macrocode}
    \special{ps:
%    \end{macrocode}
% Finally, do the outline and save the position.
%    \begin{macrocode}
        currentpoint
        stroke
%    \end{macrocode}
% Restore the original settings and position.
%    \begin{macrocode}
        /show /cntorigshow load def
      grestore
      moveto
    }%
  \endgroup
%    \end{macrocode}
% Print the main text.
%    \begin{macrocode}
  \mbox{#2}%
}
%</dvipsone>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Configuration Files}
%
% This configuration file is just a copy of a part of |graphics.cfg|
% from \TeX Live.
%    \begin{macrocode}
%<*cfgfile>
 % Select an appropriate default driver
\begingroup
  \chardef\x=0 %
  % check pdfTeX
  \@ifundefined{pdfoutput}{}{%
    \ifcase\pdfoutput
    \else
      \chardef\x=1 %
    \fi
  }%
  % check VTeX
  \@ifundefined{OpMode}{}{%
    \chardef\x=2 %
  }%
\expandafter\endgroup
\ifcase\x
  % default case
  \ExecuteOptions{dvips}%
\or
  % pdfTeX is running in pdf mode
  \ExecuteOptions{pdftex}%
\else
  % VTeX is running
  \ExecuteOptions{vtex}%
\fi
%</cfgfile>
%    \end{macrocode}
%
% \Finale