summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/textgreek/textgreek.dtx
blob: 1d8150dbcace0a8af43733c4058ecfb17484af90 (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
% \iffalse meta-comment
% Copyright 2010,2011 Leonard Michlmayr
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% 
% This work has the LPPL maintenance status `author-maintained'.
%  
% The Current Maintainer of this work is Leonard Michlmayr
% <leonard.michlmayr at gmail.com>.
% 
% This work consists of the file textgreek.dtx
% and the derived files textgreek.sty and textgreek.pdf
% \fi
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[2009/09/24]
%<package>\ProvidesPackage{textgreek}
%<package>   [2011/10/09 v0.7 Greek symbols in text]
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{textcomp}
\usepackage{textgreek}[2011/09/24]
\usepackage[american]{babel}
\usepackage{upgreek}
\usepackage{amstext}
\usepackage{microtype}
\usepackage[numbered]{hypdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{textgreek.dtx}
  \PrintChanges
  \makeatletter\c@IndexColumns = 2\makeatother
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \iffalse\OnlyDescription\fi
% \CheckSum{477}
%
% \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         \~}
%
%   \changes{v0.1}{2010/10/17}{Initial Version}
%   \changes{v0.7}{2011/10/09}{Split out the .ins file and fix the
%   argument of \cmd{\usedir}.}
%
% \GetFileInfo{textgreek.sty}
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } \DoNotIndex{\@ne}
% \DoNotIndex{\advance,\begingroup,\catcode,\closein}
% \DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup}
% \DoNotIndex{\if,\fi,\iffalse,\iftrue}
% \DoNotIndex{\edef,\csname,\endcsname,\expandafter,\gdef,\xdef}
% \DoNotIndex{\ifcat,\ifmmode,\ifx,\mbox,\noexpand,\protect,\relax}
% \DoNotIndex{\texorpdfstring}
% \DoNotIndex{\bfseries,\centering,\@xiipt,\@xivpt,\@xpt,\@xviipt,\@xxvpt}
% \DoNotIndex{\DeclareOption,\ExecuteOptions,\fontfamily,\fontsize}
% \DoNotIndex{\footskip,\hbox,\headheight,\headsep,\hfil,\hfill}
% \DoNotIndex{\hoffset,\hsize,\hspace,\kern,\MakeUppercase,\mdseries}
% \DoNotIndex{\MessageBreak,\newcommand,\newpage,\space,\noindent}
% \DoNotIndex{\oddsidemargin,\PackageError,\PackageWarning}
% \DoNotIndex{\paperwidth,\paperheight,\par,\parbox,\parindent,\parsep}
% \DoNotIndex{\ProcessOptions,\rmfamily,\selectfont,\setlength}
% \DoNotIndex{\sfdefault,\sffamily,\space,\string,\textheight,\textwidth}
% \DoNotIndex{\thinspace,\thispagestyle,\topmargin,\ttfamily,\upshape}
% \DoNotIndex{\vbox,\vfil,\voffset,\vsize,\vskip}
% \DoNotIndex{\ce,\char,\curr@fontshape,\DeclareFontEncoding}
% \DoNotIndex{\DeclareRobustCommand,\temp,\tempa,\tempb,\tempc}
% \DoNotIndex{\tempd,\tempe,\2,\3,\8}
% \DoNotIndex{\fontseries,\providecommand,\renewcommand}
% \DoNotIndex{\RequirePackage,\romannumeral,\usefont}
% \DoNotIndex{\DeclareTextCommandDefault,\@@end}
%
% \title{The \textsf{\jobname} package\thanks{This document
%     corresponds to \textsf{textgreek}~\fileversion, dated~\filedate.}}
% \author{Leonard Michlmayr \\ \texttt{leonard.michlmayr at gmail.com}}
% \date{\filedate}
%
% \maketitle
%
% \begin{abstract}
%   The \LaTeX{} package \textsf{textgreek} provides NFSS text symbols
%   for Greek letters. This way the author can use Greek letters in
%   text without changing to math mode. The usual font selection
%   commands---e.g.\  |\textbf|---apply to these Greek letters as to
%   usual text and the font is upright in an upright
%   environment. Further, \textsf{hyperref} can use these symbols in
%   PDF-strings such as PDF-bookmarks.
% \end{abstract}
%
% \tableofcontents
%
% \section{Introduction}
%
% The usual way to print Greek letters in \LaTeX{} uses the math
% mode. E.g.\ |$\beta$| produces $\beta$. With the default math
% fonts, the Greek letters produced this way are
% \textit{italic}. Generally, this is ok, since they represent
% variables and variables are typeset italic with the default math
% font settings. In some circumstances, however, Greek letters don't
% represent variables and should be typeset upright. E.g.\ in
% ``\textbeta-decay'' or ``\textmugreek A''.
% 
% The package \textsf{upgreek} provides commands to set upright Greek
% letters in math mode, but it does not provide text symbols. You
% could use them in text with |$\upbeta$-decay|, for example,
% which gives $\upbeta$-decay, but the font will always be the
% same and will not be adapted to the surrounding font.
%
% The package \textsf{textgreek} provides text commands for Greek
% letters in text that adapt to the surrounding font. For example in
% {\bf bold text, the command \verb|\textbeta| gives \textbeta{} while
% \verb|$\upbeta$| gives $\upbeta$}.
%
% As textsymbols, Greek letters can also be used in unicode
% PDF-strings, for example in PDF-bookmarks provided by the
% \textsf{hyperref} package. See section \ref{hyperref}.
%
% \section{Usage}
% The following list shows the commands provided by this package. You
% can use these commands in any context.
% \begin{multicols}{3}
% \begin{tabbing}
% |\straightepsilon|\quad\=\textOmega\quad\kill
% |\textalpha|\>\textalpha\\
% |\textbeta|\>\textbeta\\
% |\textgamma|\>\textgamma\\
% |\textdelta|\>\textdelta\\
% |\textepsilon|\>\textepsilon\\
% |\textzeta|\>\textzeta\\
% |\texteta|\>\texteta\\
% |\texttheta|\>\texttheta\\
% |\textiota|\>\textiota\\
% |\textkappa|\>\textkappa\\
% |\textlambda|\>\textlambda\\
% |\textmu|\>\textmugreek\\
% |\textmugreek|\>\textmugreek\\
% |\textnu|\>\textnu\\
% |\textxi|\>\textxi\\
% |\textomikron|\>\textomikron\\
% |\textpi|\>\textpi\\
% |\textrho|\>\textrho\\
% |\textsigma|\>\textsigma\\
% |\texttau|\>\texttau\\
% |\textupsilon|\>\textupsilon\\
% |\textphi|\>\textphi\\
% |\textchi|\>\textchi\\
% |\textpsi|\>\textpsi\\
% |\textomega|\>\textomega\\
% |\textAlpha|\>\textAlpha\\
% |\textBeta|\>\textBeta\\
% |\textGamma|\>\textGamma\\
% |\textDelta|\>\textDelta\\
% |\textEpsilon|\>\textEpsilon\\
% |\textZeta|\>\textZeta\\
% |\textEta|\>\textEta\\
% |\textTheta|\>\textTheta\\
% |\textIota|\>\textIota\\
% |\textKappa|\>\textKappa\\
% |\textLambda|\>\textLambda\\
% |\textMu|\>\textMu\\
% |\textNu|\>\textNu\\
% |\textXi|\>\textXi\\
% |\textOmikron|\>\textOmikron\\
% |\textPi|\>\textPi\\
% |\textRho|\>\textRho\\
% |\textSigma|\>\textSigma\\
% |\textTau|\>\textTau\\
% |\textUpsilon|\>\textUpsilon\\
% |\textPhi|\>\textPhi\\
% |\textChi|\>\textChi\\
% |\textPsi|\>\textPsi\\
% |\textOmega|\>\textOmega\\
% \> \\
% |\textvarsigma|\>\textvarsigma\\
% |\straightphi|\>\straightphi\\
% |\scripttheta|\>\scripttheta\\
% |\straighttheta|\>\straighttheta\\
% |\straightepsilon|\>\straightepsilon\\
% \end{tabbing}
% \end{multicols}
% The \textsf{textcomp} package also defines
% \cmd{\textmu}. \textsf{textgreek} will not replace a prior
% definition of \cmd{\textmu} if recognized. Therefore it is often
% better to use \cmd{\textmugreek} instead to avoid unexpected
% results.
% \subsection{Package Options}
% You can choose the Greek fonts used.
% \newcommand{\textsample}{\textalpha \textbeta \textgamma \textdelta
%   \textepsilon{} \textzeta\texteta\texttheta\textiota\textkappa{}
%   \textlambda\textmugreek\textnu\textxi\textomikron{}
%   \textpi\textrho\textsigma\texttau\textupsilon{}
%   \textphi\textchi\textpsi\textomega{}
%   \textAlpha\textBeta\textGamma\textDelta\textEpsilon{}
%   \textZeta\textEta\textTheta\textIota\textKappa{}
%   \textLambda\textMu\textNu\textXi\textOmikron{}
%   \textPi\textRho\textSigma\textTau\textUpsilon{}
%   \textPhi\textChi\textPsi\textOmega{}
%   \textvarsigma\straightphi\scripttheta\straighttheta\straightepsilon}
% \begin{description}
% \item[cbgreek] use the default fonts. This option is the
%   default. Font sample: {\usefont{LGR}{cmr}{m}{n}
%     \renewcommand*{\textgreekfontmap}{} \textsample{}}
% \item[euler] use the Euler fonts as a companion for all fonts except
%   Helvetica. Font sample: { \usefont{U}{eur}{m}{n} \textsample }
% \item[artemisia] use Artemisia fonts as a companion for all fonts
%   except Helvetica and Euler. Font sample:
%   {\renewcommand*{\textgreekfontmap}{}
%     \usefont{LGR}{artemisia}{m}{n} \textsample{}}
% \end{description}
%
% \subsection{Advanced commands}
% The package provides a number of options that allows to select a
% font that will be used. The list of font substitutions is written to
% the log file. \DescribeMacro{\textgreekfontmap} If you need to
% customize the font substitutions, you can redefine
% |\textgreekfontmap|. For example, the font map for the option
% \textsf{euler} may also be set by:
% \begin{verbatim}
% \renewcommand*{\textgreekfontmap}{
%   {phv/*/*}{U/psy/*/*}
%   {*/bx/n}{U/eur/b/n}
%   {*/b/n}{U/eur/b/n}
%   {*/*/n}{U/eur/m/n}
%   {*/*/it}{OML/*/*/*}}
% \end{verbatim}
% The list contains pairs of options: the font spec (without the
% encoding) of the font to be replaced and the font spec (with
% encoding) of the font to be used as companion. The wildcard * may be
% used to match any family, series, or shape respectively. The first
% match is effective. Fonts that do not matched at all will be
% substituted with the same font-family, font-series, and font-shape
% in the encoding LGR\@. Since the Euler font (eur) does not use the
% encoding LGR, it has to be replaced by U/eur/m/n.
%
% \section{Examples}
%
% Most users will use this package to get upright Greek letters, but
% you can use it for italic letters too: for example
% |\textit{\textdelta}| \textit{\textdelta}.
%
% {\usefont{T1}{phv}{m}{n} When you are using Helvetica, the font
% ``Symbol'' is used for Greek letters: \textsample}
%
% Remember that \TeX{} skips over whitespace directly following a
% command. Add |{}| to get an interword space after a
% command. E.g.\ \textsigma{} is genereted by |\textsigma{}|.
%
% \subsection{Use \textquotedblleft\textbeta-decay\textquotedblright {}
%   in a heading}
%
% The command used for the heading was
% \begin{verbatim}
% \subsection{Use \textquotedblleft\textbeta
%   -decay\textquotedblright {} in a heading}
% \end{verbatim}
%
% \section{Compatibility}\label{hyperref}
%
% If you use the package \textsf{hyperref} I recommend to use the
% option \textsf{unicode}, i.e.\ 
% |\usepackage[unicode]{hyperref}|. Hyperref will recognize the
% textgreek letters and replace them with unicode in PDF-strings.
%
% You can use \textsf{upgreek} and \textsf{textgreek} in the same
% document. If you want to use a textgreek letter inside a math
% environment, you can place it into an |\mbox| or |\textnormal|, or
% use |\text| from the package \textsf{amstext},
% e.g.\ |$\lambda||_{\text| |{\textbeta}}$|: $\lambda _{\text {\textbeta}}$.
%
% \section{Limitations}
%
% The variants \straighttheta, \straightphi, and \straightepsilon{}
% are not included in the LGR font encoding and \straightepsilon{} is
% not included in Symbol either. For the commands |\straighttheta|,
% |\straightphi|, and |\straightepsilon| the missing symbols are
% substituted from \texttt{OML/*/*/it} or Euler.
%
% You may need to customize |\textgreekfontmap| if you use other fonts
% than Computer Modern and Latin Modern.
%
% The version number of this package is still below 1.0. Many details
% may still change from version to version.
%
% \section{Copyright}
% Copyright 2010,2011 Leonard Michlmayr
% \smallskip
%
% \noindent This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license 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.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later. \smallskip
% 
% \noindent This work has the LPPL maintenance status `author-maintained'. \smallskip
%  
% \noindent The Current Maintainer of this work is Leonard Michlmayr. \smallskip
% 
% \noindent This work consists of the file textgreek.dtx
% and the derived files textgreek.sty and textgreek.pdf
% \StopEventually{}
% \section{Implementation}
% Load the LGR font encoding.
%    \begin{macrocode}
\InputIfFileExists{lgrenc.def}{%
  \PackageInfo{textgreek}{Loading the definitions for the Greek font%
    encoding.}}{%
  \PackageError{textgreek}{Cannot find the file lgrenc.def}{%
    lgrenc.def is a file that contains the definitions for the Greek
    font encoding LGR. Maybe it comes with the babel package.}}
%    \end{macrocode}
% \subsection{Package Options}
%    \begin{macrocode}
\DeclareOption{cbgreek}{%
\renewcommand*{\textgreekfontmap}{%
  {eur/*/*}{U/eur/*/*}
  {phv/*/*}{U/psy/*/*}}}%
%    \end{macrocode}
% \changes{v0.5}{2011/04/04}{use wildcards in the fontmap.}
%    \begin{macrocode}
\DeclareOption{euler}{%
\renewcommand*{\textgreekfontmap}{%
  {phv/*/*}{U/psy/*/*}
  {*/bx/n}{U/eur/b/n}
  {*/b/n}{U/eur/b/n}
  {*/*/n}{U/eur/m/n}
  {*/*/it}{OML/*/*/*}}}%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareOption{artemisia}{%
\renewcommand*{\textgreekfontmap}{%
  {eur/*/*}{U/eur/*/*}
  {phv/*/*}{U/psy/*/*}
  {*/b/n}{LGR/artemisia/b/n}
  {*/bx/n}{LGR/artemisia/bx/n}
  {*/*/n}{LGR/artemisia/m/n}
  {*/b/it}{LGR/artemisia/b/it}
  {*/bx/it}{LGR/artemisia/bx/it}
  {*/*/it}{LGR/artemisia/m/it}
  {*/b/sl}{LGR/artemisia/b/sl}
  {*/bx/sl}{LGR/artemisia/bx/sl}
  {*/*/sl}{LGR/artemisia/m/sl}
  {*/*/sc}{LGR/artemisia/m/sc}
  {*/*/sco}{LGR/artemisia/m/sco}}}%
%    \end{macrocode}
% \begin{macro}{\textgreekfontmap}
%   \changes{v0.5}{2011/04/05}{The new font matching macros support
%     the wildcard *.} Initialize
%   |\textgreekfontmap|, set the default option and process the
%   options.
%    \begin{macrocode}
\newcommand*{\textgreekfontmap}{}%
\ExecuteOptions{cbgreek}
\ProcessOptions\relax%
\PackageInfo{textgreek}{Loaded fontmap: \textgreekfontmap.}
%    \end{macrocode}
% \end{macro}
% \subsection{Font selection}
% \begin{macro}{\textgreek@findfont}
%   Chose a companion font.  \changes{v0.5}{2011/04/07}{Allow wildcards
%     in fontsspecs.}
%    \begin{macrocode}
\def\textgreek@setfont#1/#2/#3/#4\relax{%
\textgreek@ematch{#1}{*}{}{\fontencoding{#1}}%
\textgreek@ematch{#2}{*}{}{\fontfamily{#2}}%
\textgreek@ematch{#3}{*}{}{\fontseries{#3}}%
\textgreek@ematch{#4}{*}{}{\fontshape{#4}}}%
%    \end{macrocode}
%   \changes{v0.3}{2010/10/30}{Make font substitutions customizable.}
%   Process a list of font substitutions.
%    \begin{macrocode}
\def\textgreek@eof{}%
\def\textgreek@return#1#2\textgreek@eof{%
\fi#1}%
\def\textgreek@ematch#1#2#3#4{%
  \begingroup%
  \edef\tempa{#1}\edef\tempb{#2}\def\tempc{*}%
  \def\return##1##2\endgroup{\fi\endgroup##1}%
  \ifx\tempa\tempb\return{#3}\fi%
  \ifx\tempa\tempc\return{#3}\fi%
  \iftrue\return{#4}\fi%
  \endgroup}%
\def\textgreek@matchfont#1/#2/#3\relax#4#5{%
  \textgreek@ematch{#1}{\f@family}{%
    \textgreek@ematch{#2}{\f@series}{%
      \textgreek@ematch{#3}{\f@shape}{#4}{#5}}%
    {#5}}%
  {#5}%
}%
\def\textgreek@findfont@#1#2#3\textgreek@eof{%
  \textgreek@matchfont#1\relax%
  {\textgreek@setfont#2\relax}%
  {\textgreek@findfont#3\textgreek@eof}}%
\def\textgreek@findfont#1\textgreek@eof{%
  \begingroup%
  \def\temp{#1}%
  \def\return##1##2\endgroup{\fi\endgroup##1}%
  \ifx\temp\textgreek@eof\else%
  \return{\textgreek@findfont@#1\textgreek@eof}%
  \fi\endgroup}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\textgreekfont}
%   Select the Greek font encoding and apply font replacements.
%   \changes{v0.2}{2010/10/20}{apply font replacements before
%     \textbackslash selectfont}
%    \begin{macrocode}
\newcommand*{\textgreekfont}{%
  \fontencoding{LGR}%
  \edef\textgreek@fontmap{\textgreekfontmap}%
  \expandafter\textgreek@findfont\textgreek@fontmap\textgreek@eof%
  \selectfont%
}%
%    \end{macrocode}
% \end{macro}
% \changes{v0.6}{2011/09/24}{remove obsolote conversion tables
% \cs{lgrtoeuler} and \cs{lgrtosymbol}}
% \changes{v0.5}{2011/04/08}{Change the default variant for theta to
% \straighttheta} \changes{v0.5}{2011/04/04}{Recognize that the
% font-encoding of Symbol differs from LGR in some points}
% \begin{macro}{\TextGreek}
%   Produce a Greek letter using the correct font. If the font is
%   Euler or Symbol, convert to the appropriate font encoding.
%   \changes{v0.4}{2011/03/30}{Avoid the ligature that changes sigma
%     to a word-final sigma with the help of \texttt{\textbackslash
%       noboundary}}
%    \begin{macrocode}
\DeclareRobustCommand*{\TextGreek}[1]{%
\begingroup%
\textgreekfont%
\edef\tempa{\f@family}%
\let\tempd\f@encoding%
\def\tempb{eur}\def\tempc{psy}%
\def\tempe{OML}%
\ifx\tempd\tempe\textgreek@return{\lgrtoeuler#1}\fi%
\ifx\tempa\tempb\textgreek@return{\lgrtoeuler#1}\fi%
\ifx\tempa\tempc\textgreek@return{\lgrtosymbol#1}\fi%
#1%
\textgreek@eof%
\endgroup}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\TextGreek@Select}
%   The macro |\TextGreek@Select|\marg{LGR}\marg{OML}\marg{symbol}
%   will produce a Greek letter using the font set by |\textgreekfont|
%   and selcting the character from the three arguments corresponding
%   to the font encoding.
%    \begin{macrocode}
\DeclareRobustCommand*{\TextGreek@Select}[3]{%
\begingroup%
\textgreekfont%
\edef\tempa{\f@family}%
\let\tempd\f@encoding%
\def\tempb{eur}\def\tempc{psy}%
\def\tempe{OML}%
\ifx\tempd\tempe\textgreek@return{#2}\fi%
\ifx\tempa\tempb\textgreek@return{#2}\fi%
\ifx\tempa\tempc\textgreek@return{#3}\fi%
#1%
\textgreek@eof%
\endgroup}%
%    \end{macrocode}
% \end{macro}
% \subsection{Greek letter definitions}
% \subsubsection{Utility macro}
% \begin{macro}{\DeclareTextGreekSymbol}
%   \cmd{\DeclareTextGreekSymbol}\marg{letter}\marg{LGR}\oarg{OML}\oarg{U}\hskip
%   0pt plus 20pt will define |\text|\textit{letter} using the
%   character code \textlangle\textit{LGR\/}\textrangle{} for
%   LGR-encoded fonts, \textlangle\textit{OML\/}\textrangle{} for math
%   fonts including Euler, and \textlangle\textit{U\/}\textrangle{}
%   for the Symbol font. If \textlangle\textit{OML\/}\textrangle{} is
%   not provided, an LGR font will be used instead, if
%   \textlangle\textit{U\/}\textrangle{} is missing
%   \textlangle\textit{LGR\/}\textrangle{} will be used
%   instead. \changes{v0.6}{2011/09/24}{In order to improve
%   performance, do not run through the conversion tables
%   (e.g.\ \texttt{\textbackslash lgrtoeuler}) but save all the
%   encodings for each letter in the macro itself.}
%    \begin{macrocode}
\def\DeclareTextGreekSymbol#1#2{%
  \@ifnextchar[%
  {\DeclareTextGreekSymbol@{#1}{#2}}%
  {\@DeclareTextGreekSymbol{#1}{#2}%
    {\fontencoding{LGR}\fontfamily{cmr}\selectfont#2}{#2}}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\def\@DeclareTextGreekSymbol#1#2#3#4{%
  \expandafter\DeclareTextCommandDefault\csname text#1\endcsname%
  {\TextGreek@Select{#2}{#3}{#4}}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\def\DeclareTextGreekSymbol@#1#2[#3]{%
  \ifx\textgreek@eof#3\textgreek@return{%
    \DeclareTextGreekSymbol@@{#1}{#2}%
    {\fontencoding{LGR}\fontfamily{cmr}\selectfont#2}}%
  \else\textgreek@return{%
    \DeclareTextGreekSymbol@@{#1}{#2}{#3}}\fi%
  \textgreek@eof}%
%    \end{macrocode}
%    \begin{macrocode}
\def\DeclareTextGreekSymbol@@#1#2#3{%
  \@ifnextchar[%
  {\DeclareTextGreekSymbol@@@{#1}{#2}{#3}}%
  {\@DeclareTextGreekSymbol{#1}{#2}{#3}{#2}}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\def\DeclareTextGreekSymbol@@@#1#2#3[#4]{%
  \ifx\textgreek@eof#4\textgreek@return{%
    \@DeclareTextGreekSymbol{#1}{#2}{#3}{#2}}%
  \else\textgreek@return{%
    \@DeclareTextGreekSymbol{#1}{#2}{#3}{#4}}\fi%
  \textgreek@eof}%
%    \end{macrocode}
% \end{macro}
% \subsubsection{List of Greek letters}
%    \begin{macrocode}
\DeclareTextGreekSymbol{alpha}{a}[\char11]
\DeclareTextGreekSymbol{beta}{b}[\char12]
\DeclareTextGreekSymbol{gamma}{g}[\char13]
\DeclareTextGreekSymbol{delta}{d}[\char14]
%    \end{macrocode}
% Euler provides two variants of epsilon:
% {\usefont{U}{eur}{m}{n}\char15} and
% {\usefont{U}{eur}{m}{n}\char34}. Use {\usefont{U}{eur}{m}{n}\char34}
% with \cmd{\textepsilon}.
%    \begin{macrocode}
\DeclareTextGreekSymbol{epsilon}{e}[\char34]
\DeclareTextGreekSymbol{zeta}{z}[\char16]
\DeclareTextGreekSymbol{eta}{h}[\char17]
%    \end{macrocode}
%  Euler provides two variants of theta:
% {\usefont{U}{eur}{m}{n}\char18} and
% {\usefont{U}{eur}{m}{n}\char35}. Use
% {\usefont{U}{eur}{m}{n}\texttheta} for \cmd{\texttheta}.
%    \begin{macrocode}
\DeclareTextGreekSymbol{theta}{j}[\char18][q]
\DeclareTextGreekSymbol{iota}{i}[\char19]
\DeclareTextGreekSymbol{kappa}{k}[\char20]
\DeclareTextGreekSymbol{lambda}{l}[\char21]
%    \end{macrocode}
% \begin{macro}{\textmu}
%   \changes{v0.4}{2010/11/07}{Don't override \textsf{textcomp}'s
%     \texttt{\textbackslash textmu}} \changes{v0.4}{2010/11/07}{Don't
%     provide \texttt{\textbackslash textmicro} anymore.}
% \begin{macro}{\textmugreek}
%   I don't redefine |\textmu| if it is already provided by another
%   package. Use |\textmugreek| if you mean the Greek letter rather
%   than the micro symbol of the \textsf{textcomp} package.
%    \begin{macrocode}
\expandafter\ifx\csname?\string\textmu\endcsname\relax%
\DeclareTextGreekSymbol{mu}{m}[\char22]
\fi
\DeclareTextGreekSymbol{mugreek}{m}[\char22]
%    \end{macrocode}
% \end{macro}
% \end{macro}
%    \begin{macrocode}
\DeclareTextGreekSymbol{nu}{n}[\char23]
\DeclareTextGreekSymbol{xi}{x}[\char24]
\DeclareTextGreekSymbol{omikron}{o}
\DeclareTextGreekSymbol{pi}{p}[\char25]
\DeclareTextGreekSymbol{rho}{r}[\char26]
%    \end{macrocode}
% \changes{v0.5}{2011/04/07}{\texttt{\textbackslash noboundary} is
% needed only for sigma} Since the word-end sigma \textvarsigma{} is
% implemented as a ligature in LGR encoded fonts, we have to add
% \cmd{\noboundary} to get a \textsigma.
%    \begin{macrocode}
\DeclareTextGreekSymbol{sigma}{s\noboundary}[\char27][s]
%    \end{macrocode}
% \begin{macro}{\textvarsigma} Provide \textvarsigma{} as \cmd{\textvarsigma}.
% \changes{v0.5}{2011/04/04}{New symbol \textvarsigma.}
%    \begin{macrocode}
\DeclareTextGreekSymbol{varsigma}{c}[][V]
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\DeclareTextGreekSymbol{tau}{t}[\char28]
\DeclareTextGreekSymbol{upsilon}{u}[\char29]
%    \end{macrocode}
% Euler provides two variants of phi: {\usefont{U}{eur}{m}{n}\char30}
% and {\usefont{U}{eur}{m}{n}\char39}. Use
% {\usefont{U}{eur}{m}{n}\char39} for \cmd{\textphi}.
%    \begin{macrocode}
\DeclareTextGreekSymbol{phi}{f}[\char39][j]
\DeclareTextGreekSymbol{chi}{q}[\char31][c]
\DeclareTextGreekSymbol{psi}{y}[\char32]
\DeclareTextGreekSymbol{omega}{w}[\char33]
\DeclareTextGreekSymbol{Alpha}{A}
\DeclareTextGreekSymbol{Beta}{B}
\DeclareTextGreekSymbol{Gamma}{G}[\char0]
\DeclareTextGreekSymbol{Delta}{D}[\char1]
\DeclareTextGreekSymbol{Epsilon}{E}
\DeclareTextGreekSymbol{Zeta}{Z}
\DeclareTextGreekSymbol{Eta}{H}
\DeclareTextGreekSymbol{Theta}{J}[\char2][Q]
\DeclareTextGreekSymbol{Iota}{I}
\DeclareTextGreekSymbol{Kappa}{K}
\DeclareTextGreekSymbol{Lambda}{L}[\char3]
\DeclareTextGreekSymbol{Mu}{M}
\DeclareTextGreekSymbol{Nu}{N}
\DeclareTextGreekSymbol{Xi}{X}[\char4]
\DeclareTextGreekSymbol{Omikron}{O}
\DeclareTextGreekSymbol{Pi}{P}[\char5]
\DeclareTextGreekSymbol{Rho}{R}
\DeclareTextGreekSymbol{Sigma}{S}[\char6]
\DeclareTextGreekSymbol{Tau}{T}
\DeclareTextGreekSymbol{Upsilon}{U}[\char7]
\DeclareTextGreekSymbol{Phi}{F}[\char8]
\DeclareTextGreekSymbol{Chi}{Q}[][C]
\DeclareTextGreekSymbol{Psi}{Y}[\char9]
\DeclareTextGreekSymbol{Omega}{W}[\char10]
%    \end{macrocode}
% \subsubsection{Variants}
% \begin{macro}{\straightphi}
%   \changes{v0.5}{2011/04/03}{New symbol \straightphi} The phi symbol
%   \straightphi{} is a variant of phi \textphi. Sometimes this variant
%   is used specifically, e.g.\ in quantum field theory. The Unicode
%   code point is \texttt{U+03D5}.
%    \begin{macrocode}
\DeclareTextCommand{\straightphi}{PU}%
  {\83\325} % U+03D5 GREEK PHI SYMBOL
%    \end{macrocode}
% The Greek fonts aim at Greek text. Therefore the phi symbol is not
% included. I use the math symbol for italic fonts and euler else.
%    \begin{macrocode}
\DeclareTextCommandDefault{\straightphi}{%
\begingroup\textgreekfont%
\edef\tempa{\f@family}%
\edef\tempb{\f@shape}%
\def\tempc{eur}\def\tempd{psy}%
\def\tempe{it}%
\ifx\tempa\tempc\textgreek@return{\char30}\fi%
\ifx\tempa\tempd\textgreek@return{f}\fi%
\ifx\tempb\tempe\textgreek@return{%
  \fontencoding{OML}\selectfont\char30}\fi%
\textgreek@ematch{\f@series}{bx}{\fontseries{b}}{}%
\fontencoding{U}\fontfamily{eur}\selectfont\char30%
\textgreek@eof%
\endgroup}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\scripttheta}
%   \changes{v0.5}{2011/04/06}{New symbol \scripttheta} The theta
%   symbol \scripttheta{} is a variant of theta \texttheta. The Unicode
%   code point is \texttt{U+03D1}. It is available as |\scripttheta|.
%    \begin{macrocode}
\DeclareTextCommand{\scripttheta}{PU}%
  {\83\321}% U+03D1 GREEK THETA SYMBOL
%    \end{macrocode}
%    \begin{macrocode}
\DeclareTextCommandDefault{\scripttheta}{%
  \TextGreek@Select{j}{\char35}{J}}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\straighttheta}
%   \changes{v0.5}{2011/04/06}{New symbol \straighttheta} The theta
%   \straighttheta{} is presumably the common variant of theta
%   \texttheta. The cbgreek fonts and artemisia use the script
%   variant.
%    \begin{macrocode}
\DeclareTextCommand{\straighttheta}{PU}%
  {\83\270} % U+03B8 GREEK THETA SYMBOL
%    \end{macrocode}
%    \begin{macrocode}
\DeclareTextCommandDefault{\straighttheta}{%
\begingroup\textgreekfont%
\edef\tempa{\f@family}%
\edef\tempb{\f@shape}%
\def\tempc{eur}\def\tempd{psy}%
\def\tempe{it}%
\ifx\tempa\tempc\textgreek@return{\char18}\fi%
\ifx\tempa\tempd\textgreek@return{q}\fi%
\ifx\tempb\tempe\textgreek@return{%
  \fontencoding{OML}\selectfont\char18}\fi%
\textgreek@ematch{\f@series}{bx}{\fontseries{b}}{}%
\fontencoding{U}\fontfamily{eur}\selectfont\char18%
\textgreek@eof%
\endgroup}%
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\straightepsilon}
%   \changes{v0.5}{2011/04/06}{New symbol \straightepsilon} The epsilon
%   \straightepsilon{} is a variant of epsilon
%   \textepsilon.
%    \begin{macrocode}
%% U+03F5 GREEK LUNATE EPSILON SYMBOL
\DeclareTextCommand{\straightepsilon}{PU}{\83\365}%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareTextCommandDefault{\straightepsilon}{%
\begingroup\textgreekfont%
\edef\tempa{\f@family}%
\edef\tempb{\f@shape}%
\def\tempc{eur}\def\tempd{psy}%
\def\tempe{it}%
\ifx\tempa\tempc\textgreek@return{\char15}\fi%
\ifx\tempa\tempd\textgreek@return{%
  \fontfamily{eur}\fontseries{b}\selectfont\char15}\fi%
\ifx\tempb\tempe\textgreek@return{%
  \fontencoding{OML}\selectfont\char15}\fi%
\textgreek@ematch{\f@series}{bx}{\fontseries{b}}{}%
\fontencoding{U}\fontfamily{eur}\selectfont\char15%
\textgreek@eof%
\endgroup}%
%    \end{macrocode}
% \end{macro}
% \Finale
\endinput