summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/xltxtra/xltxtra.dtx
blob: 0f55ecafe236f42918585923174a0020f68096bc (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
% \iffalse
%
%!TEX encoding = UTF-8 Unicode
%
% Copyright (C) 2006 by Will Robertson <wspr81@gmail.com>
% 
% Distributable under the LaTeX Project Public License,
% version 1.3c or higher (your choice). The latest version of
% this license is at: http://www.latex-project.org/lppl.txt
%
% This work is "maintained" (as per LPPL maintenance status) 
% by Will Robertson.
% 
% This work consists of the file  xltxtra.dtx
%           and the derived files xltxtra.sty and xltxtra.pdf.
%
%
%<*internalbatchfile>
\begingroup
%</internalbatchfile>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble

  ____________________________
  The xltxtra package         
  (C) 2006  Will Robertson    
  License information appended


\endpreamble
\postamble

Copyright (C) 2006 by Will Robertson <wspr81@gmail.com>

Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) 
by Will Robertson.

This work consists of the file  \jobname.dtx
          and the derived files \jobname.sty and \jobname.pdf.

\endpostamble
\askforoverwritefalse
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}}
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\generate{\file{dtx-style.sty}{\from{\jobname.dtx}{dtx-style}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internalbatchfile>
\endgroup
%</internalbatchfile>
%
%<*driver>
\documentclass[12pt]{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\usepackage{dtx-style}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
%
%<*readme>
------------------------
THE XLTXTRA PACKAGE v0.3

This package provides a few small features that 
are useful for XeLaTeX.

It loads the fixltx2e and etex packages, and
patches a couple of other LaTeX commands: \-
for discretionary hyphenation with variable
hyphenation characters, and \textsuperscript/
\textsubscript that use the fontspec to access
real superior/inferior characters. It also
provides a parameterised logos for \TeX, 
\LaTeX and \XeTeX.

--------------
Will Robertson
2006
%</readme>
%
% \fi
%
% \errorcontextlines=999
% \makeatletter
%
% \GetFileInfo{\jobname.sty}
%
% \title{The \pkg{xltxtra} package}
% \author{Will Robertson}
% \date{\filedate \qquad \fileversion}
%
% \maketitle
% \tableofcontents
%
% \section{Introduction}
%
% This document describes the \pkg{xltxtra} package. It implements in general
% improved functionality for broken or sub-standard \LaTeX\ methods when using the
% \XeTeX\ format.
%
% Documentation is slim, and a bit ugly at this stage. I intend to improve it at some stage\dots Anyway, look through the sections to see what's contained within.
%
% \part{The \textsf{xltxtra} package}
%\iffalse
%<*package>
%\fi
% This is the package.
%    \begin{macrocode}
\ProvidesPackage{xltxtra}
  [2006/06/13 v0.2 Improvements for the XeTeX/LaTeX format]  
%    \end{macrocode}
%
% \paragraph{Required packages}
%    \begin{macrocode}
\RequirePackage{ifxetex}
\RequireXeTeX
\RequirePackage{graphicx}
\RequirePackage{fontspec}
\RequirePackage{xunicode}
%    \end{macrocode}
%
% \section{Logos}
% \DescribeMacro{\XeTeX}
% \DescribeMacro{\XeLaTeX}
% The \TeX-related logos people insist upon using need to be tuned
% on a per-font  basis. This package will (might!) eventually allow this,
% but for now, it's baby steps. The \XeTeX\ and \XeLaTeX\ logos
% are provided.
%
% The various \TeX-like logos that extend outside the regular
% vertical alphabetic bounds of running text have the unfortunate
% side-effects in \XeTeX\ of often overrunning the \cmd\baselineskip.
% Putting the logos in zero-height boxes prevents this problem.
% Actually, this problem doesn't happen anymore.
%
% Here're some examples. The default:
% \begin{example}
%   \TeX\ \XeTeX\ \LaTeX\ \XeLaTeX
% \end{example}
% Notice it's a bit tight when not using Computer Modern, as here:
% \begin{example}
%   \usefont{OT1}{cmr}{m}{n}
%   \TeX\ \XeTeX\ \LaTeX\ \XeLaTeX
% \end{example}
% This package provides a \emph{non-stable} method of specifying
% the spacings in these logos. In the future, it will hopefully adjust
% somewhat automatically.
%
% \noindent To do:
% \begin{itemize}[noitemsep]
% \item adapt \cmd\LaTeX\ to use small caps if available\dots
% \item \dots otherwise, need a scaling factor, and maybe a vertical nudge factor
% \item add other logos
% \item per-font parameters, with some defaults for common fonts
% \item add `low contrast' small caps versions, et al.
% \item probably break out the whole thing into its own package, if it works
% \end{itemize}
%
% \begin{macro}{\TeX@logo@spacing}
% \darg{Kern between T \& eX}
% \darg{Kern between Te \& X}
% \darg{Lowering amount for E in TeX}
% \darg{Kerning between L \& aTeX}
% \darg{Kerning between La \& TeX}
% \darg{Kerning between Xe \& LaTeX}
% This macro defines new \cmd\TeX\ and \cmd\XeTeX\ logos.
% Parameters must be tuned on a per-font basis:
% \begin{example}
%   \TeX@logo@spacing{-0.12em}{-0.12em}%
%     {0.5ex}{-0.3em}{-0.12em}{-0.1em}
%   \TeX\ \XeTeX\ \LaTeX\ \XeLaTeX
% \end{example}
%
% \emph{Warning!} This macro will  {\fontspec{Hoefler Text Black} definitely} change in the future.
% If you care abouts backwards compatibility in your documents, copy+paste
% the definitions below rather than using \cmd\TeX@logo@spacing.
%
%    \begin{macrocode}
\newlength\xxt@kern@Te
\newlength\xxt@kern@eX
\newlength\xxt@lower@e
\newlength\xxt@kern@La
\newlength\xxt@kern@aT
\newlength\xxt@kern@eL
\newcommand*\TeX@logo@spacing[6]{%
  \setlength\xxt@kern@Te{#1}%
  \setlength\xxt@kern@eX{#2}%
  \setlength\xxt@lower@e{#3}%
  \setlength\xxt@kern@La{#4}%
  \setlength\xxt@kern@aT{#5}%  
  \setlength\xxt@kern@eL{#6}%  
}
\DeclareRobustCommand\TeX{%
  \leavevmode
  \smash{%
    T\kern\xxt@kern@Te
    \lower\xxt@lower@e\hbox{E}\kern\xxt@kern@eX X}%
  \spacefactor1000\relax}
\DeclareRobustCommand{\LaTeX}{%
  \leavevmode
  \smash{%
  L\kern\xxt@kern@La 
  {\sbox\z@ T% 
    \vbox to\ht\z@{\hbox{\check@mathfonts 
      \fontsize\sf@size\z@ 
      \math@fontsfalse\selectfont 
      A}% 
    \vss}% 
  }% 
  \kern\xxt@kern@aT
  \TeX}}  
\DeclareRobustCommand\XeTeX{%
  \leavevmode
  \smash{%
   X\lower\xxt@lower@e
   \hbox{\kern\xxt@kern@eX
     \ifnum\XeTeXfonttype\font>0
       \ifnum\XeTeXcharglyph"018E>0
         \char"018E\relax
       \else
         \ifdim\fontdimen1\font=0pt
           \reflectbox{E}%
         \else
           \XeTeXuseglyphmetrics=1%
           \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0%
           \raise\dimen0\hbox{\rotatebox{180}{\box0}}%
         \fi
       \fi
     \else
       \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0%
       \raise\dimen0\hbox{\rotatebox{180}{\box0}}%
     \fi
   }\kern\xxt@kern@Te\TeX}}%
\DeclareRobustCommand\XeLaTeX{%
   \leavevmode
   \smash{%
    X\lower\xxt@lower@e
    \hbox{\kern\xxt@kern@eX
      \ifnum\XeTeXfonttype\font>0\relax
        \ifnum\XeTeXcharglyph"018E>0\relax
          \char"018E\relax
        \else
          \ifdim\fontdimen1\font=0pt\relax
            \reflectbox{E}%
          \else
            \XeTeXuseglyphmetrics=1\relax
            \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0\relax
            \raise\dimen0\hbox{\rotatebox{180}{\box0}}%
          \fi
        \fi
      \else
        \setbox0=\hbox{E}\dimen0=\ht0\advance\dimen0by\dp0\relax
        \raise\dimen0\hbox{\rotatebox{180}{\box0}}%        
      \fi}\kern\xxt@kern@eL\LaTeX}}
\TeX@logo@spacing{-0.15em}{-0.15em}{0.5ex}{-0.36em}{-0.15em}{-0.1em}
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \changes{v0.2}{2006/06/11}{Added \cmd\XeLaTeX\ logo. Thanks Herb!}
% \changes{v0.2}{2006/06/11}{Added TFM font check.}
% \changes{v0.2}{2006/08/12}{\cmd\TeX@logo@spacing made ``private'' and added an arg for \cmd\XeLaTeX.}
% \end{macro}
%
% \section{\eTeX\ functionality}
% Because it's just sensible, we load the package that actually
% allows \LaTeX\ to access the extra registers, etc., provided
% by \eTeX.
%    \begin{macrocode}
\RequirePackage{etex}
%    \end{macrocode}
%
% \section{Unicode footnote symbols}
% \LaTeX\ defines footnote symbols with LICRs that don't resolve well 
% with the \pkg{xunicode} package; better results can be achieved by
% using specific unicode characters.
%
% This problem is solved by the \pkg{fixltx2e} package.
%    \begin{macrocode}
\RequirePackage{fixltx2e}[2006/03/24]
%    \end{macrocode}
%
% \section{\cmd\eminnershape}
% \begin{macro}{\em}
% \begin{macro}{\emph}
% \pkg{fixltx2e}'s method for checking for ``inner'' emphasis is a little fragile in \XeTeX, because
% font slant information might be missing from the font. Therefore, we use \LaTeX's \acro{NFSS}
% information, which is more likely to be correct.
%
% \begin{example}
%   \renewcommand\eminnershape{\scshape}
%   \fontspec{Didot}
%   Nested {\em emphasis is \emph{now} fixed.}
% \end{example}
%
%    \begin{macrocode}
\DeclareRobustCommand\em 
  {\@nomath\em 
   \edef\@tempa{\f@shape}%
   \edef\@tempb{\itdefault}%
   \ifx\@tempa\@tempb 
     \eminnershape 
   \else 
     \emshape 
   \fi}
\DeclareTextFontCommand{\emph}{\em}
\let\emshape\itshape
\let\eminnershape\upshape
%    \end{macrocode}
% \changes{v0.2}{2006/08/12}{Migrated from \textsf{fontspec}.}
% \end{macro} \end{macro}
%
%
% \section{Programmming bits and pieces}
%
% Thanks to a long-ago c.t.t.\ post by Robin Fairbairns for the code how to \cmd\let\ a robust macro.
%    \begin{macrocode}
\newcommand*\robust@let@nc[2]{%
  \expandafter\let\expandafter#1\csname #2 \endcsname}
%    \end{macrocode}
%
% \section{\cmd\-}
% \LaTeX\ defines the macro \cmd\-\ to insert discretionary hyphenation points.
% However, it is hard-coded to use the hyphen |-| character. Since \pkg{fontspec}
% makes it easy to change the hyphenation character on a per font basis, it would
% be nice if \cmd\-\ adjusted automatically.
%
% \begin{macro}{\-}
% This macro is courtesy of Frank Mittelbach and the \LaTeXe\ source code.
%    \begin{macrocode}
%\CheckCommand\-{\discretionary{-}{}{}}
\DeclareRobustCommand{\-}{%
  \discretionary{%
    \char\ifnum\hyphenchar\font<\z@
           \xlx@defaulthyphenchar
         \else
           \hyphenchar\font
         \fi}{}{}}
\def\xlx@defaulthyphenchar{`\-}
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented; from the \LaTeXe\ sources.}
% \end{macro}
%
% \section{\cmd\textsuperscript\ and \cmd\textsubscript}
%
% The new macros now allow real text inferiors and superiors:
% \begin{quotation}
%	\fontspec{Hoefler Text}
%	  |\textsuperscript     | \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890}\par
%	  |\textsubscript       | \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890}
% \end{quotation}
% As opposed to fake ones:
% \begin{quotation}
%	\fontspec{Hoefler Text}
%	  |\textsuperscript*    | \textsuperscript*{abcdefghijklmnopqrstuvwxyz1234567890}\par
%	  |\textsubscript*      | \textsubscript*{abcdefghijklmnopqrstuvwxyz1234567890}
% \end{quotation}
% Or:
% \begin{quotation}
%	\fontspec{Hoefler Text}
%	  |\faketextsuperscript | \textsuperscript*{abcdefghijklmnopqrstuvwxyz1234567890}\par
%	  |\faketextsubscript   | \textsubscript*{abcdefghijklmnopqrstuvwxyz1234567890}
% \end{quotation}
% But beware fonts lacking the full repertoire: (this is Adobe Jenson Pro)
% \begin{quotation}
%	\fontspec{Adobe Jenson Pro}
%	  |\textsuperscript     | \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890}\par
%	  |\textsubscript       | \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890}
% \end{quotation}
%
% For OpenType fonts, the subscript feature (|subs|) is used, but if that doesn't
% exist then the scientific inferior feature (|sinf|) is used on the assumption
% that something's better than nothing. This assumption may prove to be a poor one,
% and the functionality of the package may change in the future.
%
% \begin{macro}{\faketextsubscript}
% \begin{macro}{\faketextsuperscript}
% The old (`fake') methods:
%    \begin{macrocode}
\robust@let@nc\faketextsubscript{textsubscript} 
\robust@let@nc\faketextsuperscript{textsuperscript} 
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
% \begin{macro}{\textsubscript}
% \begin{macro}{\textsubscript*}
% Text subscripts:
%    \begin{macrocode}
\DeclareRobustCommand*\textsubscript{%
  \@ifstar{\faketextsubscript}{\@@textsubscript}}
\newcommand\@@textsubscript[1]{%
  \begingroup
    \c@zf@script 1818326126\relax
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@set@font@type
    \ifzf@atsui
      \zf@make@aat@feature@string{10}{2}%
      \unless\ifx\zf@thisfontfeature\@empty
        {\addfontfeature{VerticalPosition=Inferior}#1}%
      \else
        \faketextsubscript{#1}%
      \fi
    \fi
    \ifzf@icu
      \zf@check@ot@feat{+subs}%
      \if@tempswa
        {\addfontfeature{VerticalPosition=Inferior}#1}%
      \else
        \zf@check@ot@feat{+sinf}%
        \if@tempswa
          {\addfontfeature{VerticalPosition=ScientificInferior}#1}%
        \else
          \faketextsubscript{#1}%
        \fi
      \fi
    \fi
  \endgroup}
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
% \begin{macro}{\textsuperscript}
% \begin{macro}{\textsuperscript*}
% Text superscripts:
%    \begin{macrocode}
\DeclareRobustCommand*\textsuperscript{%
  \@ifstar{\faketextsuperscript}{\@@textsuperscript}}
\newcommand\@@textsuperscript[1]{%
  \begingroup
    \c@zf@script 1818326126\relax
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@set@font@type
    \ifzf@atsui
      \zf@make@aat@feature@string{10}{1}%
      \unless\ifx\zf@thisfontfeature\@empty
        {\addfontfeature{VerticalPosition=Superior}#1}%
      \else
        \faketextsuperscript{#1}%
      \fi
    \fi
    \ifzf@icu
      \zf@check@ot@feat{+sups}%
      \if@tempswa
        {\addfontfeature{VerticalPosition=Superior}#1}%
      \else
        \faketextsuperscript{#1}%
      \fi
    \fi
  \endgroup}
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
%
% \section{\cmd\vfrac}
% A command for setting vulgar fractions based on AAT or OpenType font features. 
% Not really recommended for many purposes, depending on your text, but it's a good example.
% \begin{example}
%   \fontspec{Hoefler Text}
%   AAT: \vfrac{123}{456}\par
%   \fontspec{Warnock Pro}
%   ICU: \vfrac{123}{456}
% \end{example}
% \begin{macro}{\vfrac}
% \darg{Numerator}
% \darg{Denominator}
% No error checking is done to ensure that the font actually has the neceessary features.
% Requires the \pkg{xunicode} package for \cmd\textfractionsolidus.
%    \begin{macrocode}
\newcommand*\vfrac[2]{%
  \begingroup
    \c@zf@script 1818326126\relax
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@set@font@type
    \ifzf@atsui
      {\addfontfeature{VerticalPosition=Superior}#1}%
       \textfractionsolidus
      {\addfontfeature{VerticalPosition=Inferior}#2}%
    \fi
    \ifzf@icu
      {\addfontfeature{VerticalPosition=Numerator}#1}%
       \textfractionsolidus
      {\addfontfeature{VerticalPosition=Denominator}#2}%      
    \fi
  \endgroup}
%    \end{macrocode}
% \changes{v0.1}{2006/05/03}{Implemented.}
% \end{macro}
%
% \section{Named glyphs}
% Along the way somewhere, \XeTeX\ added support for selecting glyphs from a TrueType-based OpenType font based on their internal glyph name. Jonathan Kew posted the following definition as a nice interface to it.
% \begin{example}
%   \fontspec{Charis SIL}
%   \namedglyph{yen}
%   \namedglyph{smile}
% \end{example}
% \begin{macro}{\namedglyph}
% \darg{Name of the font glyph to be typeset}
%    \begin{macrocode}
\newcommand\namedglyph[1]{%
  \@tempcnta=\XeTeXglyphindex "#1"\relax
  \ifnum\@tempcnta>0 
    \XeTeXglyph\@tempcnta 
  \else 
    \xxt@namedglyph@fallback{#1}%
  \fi}
%    \end{macrocode}
% \changes{v0.2}{2006/08/12}{Implemented.}
% \end{macro}
% \begin{macro}{\xxt@namedglyph@fallback}
% Redefine this macro to change how glyph names that aren't found get typeset.
%    \begin{macrocode}
\newcommand\xxt@namedglyph@fallback[1]{[#1]}
%    \end{macrocode}
% \changes{v0.2}{2006/08/12}{Implemented.}
% \end{macro}
%
%\iffalse
%</package>
%\fi
%
% \clearpage
% \PrintChanges
%
% \clearpage
% \PrintIndex
%
% \Finale
%
%\iffalse
%<*dtx-style>
%    \begin{macrocode}
\ProvidesPackage{dtx-style}

\def\@dotsep{1000}
\setcounter{tocdepth}{2}
\setlength\columnseprule{0.4pt}
\renewcommand\tableofcontents{\relax
  \begin{multicols}{2}[\section*{\contentsname}]\relax
    \@starttoc{toc}\relax
  \end{multicols}}

\setcounter{IndexColumns}{2}
\renewenvironment{theglossary}
  {\small\list{}{}
     \item\relax
     \glossary@prologue\GlossaryParms 
     \let\item\@idxitem \ignorespaces 
     \def\pfill{\hspace*{\fill}}}
  {\endlist}

\usepackage{array,booktabs,calc,color,enumitem,fancyvrb,graphicx,ifthen,longtable,refstyle,varioref}
\usepackage{fontspec,ifxetex,xunicode,xltxtra}
\setromanfont[WordSpace=0.9,Mapping=tex-text,
  BoldFont=Hoefler Text,
  ItalicFeatures={Contextuals={NoWordFinal,NoLineFinal}}]{Hoefler Text}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text,BoldFont=Gill Sans]{Gill Sans}
\setmonofont[Scale=MatchLowercase]{Andale Mono}

\linespread{1.05}      % A bit more space between lines
\frenchspacing         % Remove ugly extra space after punctuation
  
\definecolor{niceblue}{rgb}{0.2,0.4,0.6}
\newenvironment{example}
  {\VerbatimEnvironment
   \par\noindent\hrulefill\nobreak\par\nobreak
   \begin{VerbatimOut}[gobble=4]{\examplefilename}}
  {\end{VerbatimOut}\relax
   \begingroup
     \color{niceblue}
     \typesetexample
   \endgroup\nobreak\par\nobreak\noindent\hrulefill\nobreak\par}

\let\examplesize\normalsize
\let\auxwidth\relax

\newlength\examplewidth\newlength\verbatimwidth
\newlength\exoutdent   \newlength\exverbgap
\setlength\exverbgap{0em}
\setlength\exoutdent{-0\textwidth}
\newsavebox\verbatimbox
\edef\examplefilename{\jobname.example}

\newcommand\typesetexample{\relax
   \begin{lrbox}{\verbatimbox}\relax
     \BVerbatimInput[fontsize=\small]{\examplefilename}\relax
   \end{lrbox}
   \begin{list}{}{\setlength\itemindent{0pt}
                  \setlength\leftmargin\exoutdent
                  \setlength\rightmargin{0pt}}\item
   \ifx\auxwidth\relax
     \setlength\verbatimwidth{\wd\verbatimbox}\relax
   \else
     \setlength\verbatimwidth{\auxwidth}\relax
   \fi
   \begin{minipage}[c]{\textwidth-\exoutdent-\verbatimwidth-\exverbgap}
     \catcode`\%=14\centering\examplesize\input\examplefilename\relax
   \end{minipage}\hfill
   \begin{minipage}[c]{\verbatimwidth}
     \usebox\verbatimbox
   \end{minipage}
   \end{list}
   \global\let\examplesize\normalsize}

\newcommand*\setexsize[1]{\let\examplesize#1}
\newcommand*\setverbwidth[1]{\def\auxwidth{#1}}

\newcommand*\name[1]{{#1}}
\newcommand*\pkg[1]{\textsf{#1}}

\newcommand*\acro[1]{\textsc{\MakeLowercase{#1}}}

\newcommand*\note[1]{\unskip\footnote{#1}}

\let\latin\textit
\def\eg{\latin{e.g.}}
\def\Eg{\latin{E.g.}}
\def\ie{\latin{i.e.}}
\def\etc{\@ifnextchar.{\latin{etc}}{\latin{etc.}\@}}

\def\OMEGA{Ω}

\newcounter{argument}
\g@addto@macro\endmacro{\setcounter{argument}{0}}
\newcommand*\darg[1]{%
  \stepcounter{argument}%
  \noindent{\ttfamily\#\theargument}:~#1\par\nobreak}
\newcommand*\doarg[1]{%
  \stepcounter{argument}%
  \noindent{\ttfamily\makebox[0pt][r]{[}\#\theargument]}:~#1\par\nobreak}
%    \end{macrocode}
%</dtx-style>
%\fi
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by XeTeX:}
% \typeout{*}
% \typeout{* \space\space\space xltxtra.sty}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput