-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathucs.dtx
6013 lines (5974 loc) · 252 KB
/
ucs.dtx
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
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \iffalse meta-comment
% -*-coding: utf-8; mode: latex;-*-
%
%<*driver>
\ProvidesFile{ucs.dtx}[2024/03/27 v2.5
UCS: Master document for generating documentation for ucs.sty]
%
\documentclass{ltxdoc}
%\usepackage[postscript]{ucls}
\usepackage[utf8x]{inputenc}
%\usepackage[univerb]{ucsutils}
\def\SetUnicodeOption#1{}
\setcounter{section}{-1}
\usepackage[T2A,T1]{fontenc}
\usepackage[hyperindex,unicode]{hyperref}
%\makeatletter
%\IfFileExists{srcltx.sty}{
% \usepackage{srcltx}
% \src@everypar{\the\everypar\src@spec}
% \gdef\MainFile{\jobname.dtx}
%}{}
%
\newcommand\tobe{%
\typeout{*** TO BE DONE ***}%
[[[ TO BE DONE ]]]}
\newcommand\univerbtt{\ttfamily\frenchspacing\univerb}
%\overfullrule=10pt
\setcounter{IndexColumns}{2}
\GetFileInfo{ucs.sty}
\CodelineIndex
%\PageIndex
\RecordChanges
\EnableCrossrefs
%\DisableCrossrefs
%\OnlyDescription
\begin{document}
\DocInput{ucs.dtx}
\end{document}
%</driver>
% \fi
%
% \changes{v1.99}{2004/10/17}{Last version by Dominique Unruh}
% \changes{v2.0}{2012/04/20}{Switched to LPPL~1.3}
% \changes{v2.0}{2012/04/20}{Changed the \texttt{mathletters} mappings of some greek small letters
% from \cs{var\textit{letter}} to \cs{\textit{letter}} in order to
% conform to the Unicode standard}
% \changes{v2.0}{2012/04/20}{Added \texttt{mathletters} mappings for variants of greek small
% letters}
% \changes{v2.0}{2012/04/20}{Switched from \cs{mathbbm} to \cs{mathbb} for double-struck characters}
% \changes{v2.0}{2012/04/20}{Added support for various symbols}
% \changes{v2.0}{2012/04/20}{Created makefile}
% \changes{v2.0}{2012/04/20}{Various small improvements}
% \changes{v2.1}{2012/08/28}{Added support for various arrows, musical notes, and NON-BREAKING
% HYPHEN}
% \changes{v2.1}{2012/08/28}{Some small bug fixes}
% \changes{v2.2}{2013/05/11}{Fixed a bug related to the optional definition of \cs{@ifnextchar} (see
% \url{http://tinyurl.com/dxncfn9})}
% \changes{v2.5}{2024/03/27}{clear option list for github issue 2}
% ^^A FIXME: The page number of the changelog entry for the \show removal mentions page 48, although
% ^^A the code appears on page 50.
% ^^A FIXME: There are no index entries for macro descriptions (only for macro definitions and
% ^^A usage).
% ^^A FIXME: The index entries do not use hyperlinks.
%
% \expandafter\let\expandafter\percent\csname @percentchar\endcsname
% \let\ucsdocmfour1^^A
% \let\xsection\section
%\ProvidesFile{ucs-doc.tex}[2024/03/27 v2.5 Main documentation for package ucs]
%
%\ifx\ucsdocmfour\undefined
%\documentclass{ltxdoc}
%\overfullrule=10pt
%\usepackage[utf8x]{inputenc}
%\usepackage[T1]{fontenc}
%\newcommand\tobe{^^A
% \typeout{*** TO BE DONE ***}^^A
% [[[ TO BE DONE ]]]}
%\makeatletter
%\let\percent\@percentchar
%\begin{document}
%\fi
%
%\title{\texttt{ucs.sty} - Unicode Support}
%\author{Dominique~P.~G.~Unruh\\Wolfgang Jeltsch\\David Carlisle (2022
%update)\thanks{\url{https://github.com/LaTeX-Package-Repositories/ucs}}}
%\maketitle
%
%\MakeShortVerb{\|}
%
%\makeatletter
%
%^^A\newcommand\task[1]{\fbox{\textbf{#1}}}
%\newcommand\args[1]{\settowidth{\synwidth}{Synopsis: }Synopsis:
% \texttt{#1}\\}
%\newlength{\synwidth}
%\newcommand\breakindent{\hskip0ptplus1fill^^A
% \penalty0^^A
% \hskip0ptplus-1fill^^A
% \hskip-\synwidth^^A
% \null\nobreak\hskip\synwidth\relax}
%^^A\newcommand\marg[1]{\{\meta{#1}\}\breakindent}
%^^A\newcommand\oarg[1]{[\meta{#1}]\breakindent}
%\newenvironment{local}[1]
% {\begin{macro}{#1}{\tiny (local)}}
% {\end{macro}}
%\newenvironment{local*}[1]
% {\begin{macro}{#1}}
% {\end{macro}}
%\let\bs=\bslash
%\def\SpecialMainOptionIndex#1{\@bsphack\special@index{^^A
% #1\actualchar
% {\string\ttfamily\space#1}
% (option)^^A
% \encapchar main}^^A
% \special@index{options:\levelchar{^^A
% \string\ttfamily\space#1}\encapchar
% main}\@esphack}
%\def\SpecialOptionIndex#1{\@bsphack
% \index{#1\actualchar{\protect\ttfamily#1}
% (option)\encapchar usage}^^A
% \index{options:\levelchar{\protect\ttfamily#1}\encapchar
% usage}\@esphack}
%\def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters
% \Describe@Option}
%\def\Describe@Option#1{\endgroup
% \marginpar{\raggedleft\PrintDescribeEnv{#1}}^^A
% \SpecialOptionIndex{#1}\@esphack\ignorespaces}
%\def\PrintDescribeMacro#1{\strut \MacroFont \llap{\string #1}\ }
%
%\makeatother
%
%\parindent=0pt
%\parskip=\medskipamount
%
%\tableofcontents
%
%\section{2022 Update Notes}
% \large\bfseries
% When |ucs/uf8x| was first written, its Unicode support was far
% more extensive than the standard release, and users could simply
% opt in via the |[utf8x]| option. In the years since then Standard
% \LaTeX\ Unicode support has been extended and enabled by default.
% Various features such as filenames, |\label| arguments and upper/lower
% case changing now work by default with UTF-8, but assuming the standard
% implementation.
%
% With the June 2022 \LaTeX\ release these incompatibilities meant
% that simply loading |inputenc| with the |utf8x| option could produce
% low level \TeX\ errors.
%
% The original maintainers kindly allowed the \LaTeX\ project members
% to make the releases from |2022/08/07 v2.3|. .
%
% The remaining documentation is unchanged but version 2.3 introduces
% the following changes, and version 2.4 aborts with a warning if used with Unicode TeX.
%
% \begin{itemize}
% \item If a document uses |\usepackage[utf8x]{inputenc}| when the
% |ucs| package has \emph{not} been loaded, a message is issued on the
% terminal, and the standard |[utf8]| option is used instead.
%
% The warning can be avoided by simply deleting\\
% |\usepackage[utf8x]{inputenc}|\\
% as UTF-8 is the default encoding.
%
% \item If the |ucs| package is loaded explicitly, then the |utf8x.def|
% file is input in the normal way. |utf8x.def| and |ucs.sty| have both
% been modified to be more compatible with current \LaTeX\ releases.
% Notably making the active characters |\protected| so that they work
% with the new |\MakeUppercase|.
%
% \end{itemize}
%
% \normalsize\normalfont
%
%\section{Usage}
%
%Simply use |\usepackage{ucs}| and |\usepackage[utf8x]{inputenc}|,
%then you will be able
%to write your LaTeX-Documents in UTF-8.
%
%You can access a Unicode character with
%\texttt{\bs unichar\{\meta{code}\}}, even when the active input encoding is
%not |utf8|.
%
%An unicode character can have an default glyph macro and several glyph
%macros associated with options. If one of these options is set, the
%associated macro is used, otherwise the default macro. If several
%associated options
%are set, an error is yielded. You may activate an option \meta{name} by
%including it in the option list while loading the ucs package, or by
%using \DescribeMacro{\SetUnicodeOption}^^A
%\texttt{\bslash SetUnicodeOption\{\meta{name}\}}. To deactivate an
%option, prefix its name by |no|. Note that you must load |ucs.sty|
%before |\usepackage[utf8x]{inputenc}| if you want to supply options.
%Any option which you want to use
%must be used at least once in the preamble.
%
%When you activate an option, you can supply a priority as optional argument.
%If there are several glyphs for a given code position, the one having the
%option with the highest priority is taken (an error is yielded in case of
%ambiguity). If you do not supply a priority, 100 is taken as default.
%``Normal'' glyphs are associated with the option |default|, which is
%initially activated with a priority of 0.
%
%NB: UTF-8 characters are interpreted by \TeX{}
%as a sequence of commands, so don't use calls like
%\texttt{\bslash macro ä} instead of
%\texttt{\bslash macro\{ä\}} (this does not apply to ASCII characters).
%
%This input encoding does not change the fontencoding automatically. For that
%purpose, you can use |autofe.sty|, which is included in the ucs package.
%
%\subsection{Special options}
%
%Several options have a special hardcoded meaning:
%\begin{itemize}
%\item |combine|: \DescribeOption{combine}Activates combining mode. See
% section \ref{combiningmode}.
%\item |default|: \DescribeOption{default}This option contains all
% characters, which are not explicitly associated with another option.
% But see also the option |document|. This option is activated per
% default, but has priority 0, i.e.~any other activated option is
% prefered, unless its priority is explicitly given to be smaller.
%^^A
%\item |document|: \DescribeOption{document}Every character you define
% in your document using |\Declare|\-|UnicodeCharacter| has the option
% |document|. This option is activated per default having the priority
% 1000, therefore manually declared characters take precedence over
% all other characters, unless some other option has explicitly gotten
% a higher priority.
%\item |fasterrors|: \DescribeOption{fasterrors}When used, the name of
% an unicode character is not
%included in error messages any more, which runs much faster.
%\item |graphics|: \DescribeOption{graphics}^^A
%When used, unknown characters are replaces by GIFs
%downloaded from |unicode.org|. Commands to download and convert these are
%executed if -shell-escape is passed to \LaTeX, otherwise they are proposed
%to the user in a warning message. A UNIX-machine supporting the commands
%|wget|, |giftopnm| and |pnmtops| is assumed.
%\item |savemem|: \DescribeOption{savemem}^^A
%When used, only the character needed at the moment is
%loaded, not a whole page. This slows down operation, but saves space in the
%\TeX-pool, especially with sparsly used character set like kanji. Use this,
%if you get an out of pool error or similar
%from \TeX. If you change the state of this
%option during the run, you may get inexpected results.
%\item |warnunknown|: \DescribeOption{warnunknown}^^A
%When used, an unknown unicode character does not
%generate an error, but a warning.
%\end{itemize}
%
%\subsection{Normal options}
%
%The options described here are---strictly spoken---not part of
%|ucs.sty|, but are defined by the unicode data files. They are included
%here for convenience.
%\begin{itemize}
%
%\item |autogenerated|: \DescribeOption{autogenerated}^^A
%This enables the characters, which are autogenerated as composition
%of other characters according to the informations in the UnicodeData.txt.
%These may or may not look good. You may have to define the |\unicodecircle|,
%|\unicodesquare|, |\unicodevertical|, |\unicodewide| and |\unicodesmall|
%macros to let all autogenerated macros work.
%Furthermore you may have to set some other options, when the autogenerated
%characters are build out of characters, which are not in the default set.
%
%\item |cjkbg5|: \DescribeOption{cjkbg5}^^A
%See the explanation for |cjkjis| below and substitute C40 by C00,
%JIS by BIG-5 and |kanji48| by some appropriate font which has BIG-5 encoding
%(e.g. one of the "Arphic AR PL * Big5" fonts).
%
%\item |cjkgb|: \DescribeOption{cjkgb}^^A
%See the explanation for |cjkjis| below and substitute C40 by C10,
%JIS by GB and |kanji48| by some appropriate font which has GB encoding
%(e.g. one of the "Arphic AR PL * GB" fonts).
%
%\item |cjkhangul|: \DescribeOption{cjkhangul}^^A
%See the explanation for |cjkjis| below and substitute C40 by C61,
%JIS by ``KSC5601 hangul syllables'' and |kanji48| by some appropriate
%font which has KSC5601 encoding and hangul syllables
%(e.g. the |han| or the |han1| font from CJK-\LaTeX).
%
%\item |cjkjis|: \DescribeOption{cjkjis}^^A
%This enables the use of C40 (JIS) or C42 (JISdnp) encoded fonts.
%You need to have the |c40*.fd| files
%which are contributed with the package |CJK|
%and the |kanji48| font installed for this.
%Further you have to load the
%fontencoding |C40| (an option to the package |fontenc|).
%
%It is not necessary to load the package |CJK|. If you want to use it nevertheless
%take care of the following:
%\begin{itemize}
%\item Load |CJK| before |fontenc|, or quite strange errors will occur.
%\item Load |CJK| with option |encapsulated|, or it will overwrite some of the
%UTF8 input encoding.
%\item
%Don't use the |CJK| environment, it destroys the input encoding.
%Use |ucjk| instead, which is a patched version and takes no arguments.
%\end{itemize}
%
%\item |fullmathletters|: \DescribeOption{fullmathletters}^^A
%This option has been removed. Replace all occurrences by |mathletters|.
%
%\item |mathletters|: \DescribeOption{mathletters}^^A
%When using this option is set, some unicode code
%characters like greek or some hebrew letters generate the math mode
%glyphs. This option is disabled by default, because using math greek in a
%normal text does not look good. But you may set it in |\everymath| and
%|\everydisplay| and such enable the use of unicode characters in math mode.
%You can also use this to get a poor man's greek, it is however recommended
%to use the |cb| fonts instead.
%
%\item |postscript|: \DescribeOption{postscript}^^A
%This option enables use of postscript, e.g. of postscript fonts.
%Some DVI-viewers may have problems with documents using this option,
%but most viewers can handle it correctly.
%
%\item |privatecsur|: \DescribeOption{privatecsur}^^A
%This option enables use of characters in the private area according to
%the mapping by the ConScript Unicode Registry
%{(\def\-{\discretionary{}{}{}}^^A
%\texttt{http://\-www.evertype.com/\-standards/\-csur/} and also
%\texttt{http://\-home.ccil.org/\-\textasciitilde
%cowan/\-csur/\-index.html})}.
%
%\item |tipa|: \DescribeOption{tipa}^^A
%This enables the use of the macros in the |tipa| package to display IPA
%symbols.
%
%\end{itemize}
%
%\subsection{Combining mode}\label{combiningmode}
%
%\def\latinc{\textsc{U+0063 latin small letter c}}
%\def\acuteacc{\textsc{U+0301 combining acute accent}}
%In some cases, Unicode documents contain sequences like \latinc\space\acuteacc
%(producing {^^A
%\'c). In order to typeset them
%correctly, we cannot render \latinc immediately when it occurs,
%instead we have to wait whether some combining character is going to
%follow.
%
%\DescribeOption{combine}^^A
%To enable this way of parsing in |ucs.sty|, we have to use the option
%|combine|. As long as this option is in effect, characters are not
%immediately rendered, but stored in a token register until they are
%output via
%\begin{itemize}
%\item resetting of the option (|\SetUnicodeOption{nocombine}|) or
%\item \DescribeMacro{\unicodecombine}^^A
% the command |\unicodecombine|.
%\end{itemize}
%
%Since characters handled by |ucs.sty| are not immediately output while
%ASCII characters are handled by \TeX and directly rendered, you should
%not mix ASCII characters and non-ASCII characters while this option is
%in effect. Thus to obtain the above glyph, you cannot use\\
%\null\qquad
%|\SetUnicodeOption{combine}|\texttt{c\'o}|\SetUnicodeOption{nocombine}|\\
%(where \texttt{\'o} is \acuteacc), instead you can use one of the
%following constructions:
%\begin{itemize}
%\item |\SetUnicodeOption{combine}\unichar{"63}|\texttt{\'o\percent}\\
% |\SetUnicodeOption{nocombine}|
%\item
% |\SetUnicodeOption{combine}\unicodevirtual{c}|\texttt{\'o\percent}\\
% |\SetUnicodeOption{nocombine}| (\DescribeMacro{\unicodevirtual}^^A
% |\unicodevirtual| takes arbitrary \LaTeX\space code and inserts it,
% as thou it was a Unicode character; do not use Unicode characters
% inside |\unicodevirtual|).
%\item
% \MakeShortVerb\!\DeleteShortVerb\|^^A
% !\SetUnicodeOption{combine}\myverbatim|!\texttt{c\'o|\percent}\\
% !\SetUnicodeOption{nocombine}!^^A
% \MakeShortVerb\|\DeleteShortVerb\!^^A
% \\
% where |\myverbatim|\footnote{This command is not provided by
% \texttt{ucs.sty}, but some similar command may appear in future.}
% is a command similar to |\verb|, but setting the catcodes of the
% ASCII characters to 13 (active) and then defining character no.~$n$
% to expand to |\unichar{|$n$|}|.
%\end{itemize}
%
%In cases where you only want to render occasional words containing
%combining characters and \emph{no} ASCII, you can use a macro like\\
%\null\qquad|\newcommand\combword[1]{|^^A
% |\SetUnicodeOption{combine}#1|\texttt{\percent}\\
% \null\qquad\qquad|\SetUnicodeOption{nocombine}}|\\
%and then simply typeset the concerning word as an argument to
%|\combword|.
%
%
%\subsection{Defining unicode data}
%
%A unicode character may be defined by\\
%\null\qquad
%\DescribeMacro{\DeclareUnicodeCharacter}^^A
%\texttt{\bs DeclareUnicodeCharacter\{\meta{code}\}\{\meta{macro}\}}\\
%or, when it is to be associated with a special option, by using\\\
%\null\qquad
%\DescribeMacro{\DeclareUnicodeCharacterAsOptional}^^A
%\texttt{\bs DeclareUnicodeCharacterAsOptional\{\meta{code}\}^^A
% \{\meta{option}\}\{\meta{macro}\}}\\
%where \meta{code} is the unicode character number, \meta{option} the
%associated option and \meta{macro} the glyph's macro.
%
%This definition is local.
%
%In the automatically loaded data files |\uc@dclc| should be used instead.
%
%An option \meta{option} can be defined by\\
%\null\qquad
%\DescribeMacro{\DeclareUnicodeOption}^^A
%\texttt{\bs DeclareUnicodeOption[\meta{pkg}]\{\meta{option}\}}.\\
%If \meta{pkg} is supplied, the option is set, if the package \meta{pkg}
%is loaded.
%
%You can add further packages, which automatically set an option, by\\
%\null\qquad
%\DescribeMacro{\LinkUnicodeOptionToPkg}^^A
%\texttt{\bs LinkUnicodeOptionToPkg\{\meta{option}\}\{\meta{pkg}\}}.
%
%If a character $c$ is unknown, it is looked up in
%in the \texttt{uni-$n$.def}-file,
%whereby ${n=\lfloor\frac{c}{256}\rfloor}$. So characters which are not
%document specific,
%should be defined in those file. For generating them, you should you the
%program |makeunidef.pl|.
%
%You may find |\dirtyunicode| and |\UnicodeNeeds| interesting for
%writing glyphs macros, see in the implementation section.
%
%\subsection{Known problems}
%
%Note, that if a character from some not yet loaded Unicode page
%appears, a file has to be loaded. If this appears inside a word,
%kerning and ligatures do not work at that position.
%
%Further there are some commands, which expand their arguments in
%non-executing contexts, this makes it impossible for |ucs.sty| to load
%the character definition file at this place if this has not yet been
%done. In this case the concerning character is replaced by some
%message that you have to use |\PrerenderUnicode{|\dots|}|.
%
%\def\greekalpha{\textsc{U+03B1 greek small letter alpha}}
%Both problems can be solved by preloading the offending characters. If
%you have for example \greekalpha, which should be preloaded, simply use
%\begin{itemize}
%\item \DescribeMacro{\PreloadUnicodePage}^^A
% |\PreloadUnicodePage{3}| (the argument to |\PreloadUnicodePage|
% is $\lfloor\frac n{256}\rfloor$, where $n$ is the number of the
% character (here $\textrm{0x3B1}=945$)) or
%\item \DescribeMacro{\PrerenderUnicode}^^A
% |\PrerenderUnicode{|$\alpha$|}| (the argument to
% |\PrerenderUnicode| can contain any \LaTeX\space code, which is then
% rendered in an hbox, all still unknown characters a loaded and the
% result is thrown away; do not use e.g. |\footnote| or other commands which
% might not like to be executed several times).
%\end{itemize}
%
%\section{Thanks}
%
%Thanks to\dots\nopagebreak
%\begin{itemize}
%\item Michel Goossens who supplied many characters
%(e.g. Vietnamese, polytonic Greek),
%\item Manuel Kauers for testing my package
%before the first upload,
%\item Werner Lemberg, who wrote the |CJK| package, where I got the font
%definitions in |cenccmn.tex| from,
%\item Karsten Tinnefeld for
%many of the glyph macros in |cyrillic.ucf|,
%\item Pablo Rodriguez for reporting many bugs, especially concerning
% the interaction between |ucs.sty| and other packages.
%\item Stefan Röhrich for testing my package
%before the first upload,
%\item the authors of all those many \LaTeX-packages for different scripts.
%\end{itemize}
%
%
%\ifx\ucsdocmfour\undefined
%\end{document}
%\fi
%^^A
%
% \StopEventually{\PrintIndex}
% \section{Implementation}
% \let\xsection\subsection
%
% \xsection{File \texttt{ucs.sty}}
% \begin{macrocode}
%<*ucs.sty>
% \end{macrocode}
% \begin{macrocode}
\ifx\ProvidesPackage\undefined\else
\ProvidesPackage{ucs}[2024/03/27 v2.5 UCS: Unicode input support]%
\fi
\ifx\Umathchar\undefined\else
\ifx\PackageWarningNoLine\undefined\else
\PackageWarningNoLine{ucs}{ucs package ignored with utf8 based engines}
\fi
\expandafter\let\csname [email protected]\endcsname\@empty
\expandafter\endinput
\fi
% \end{macrocode}
% \begin{macrocode}
% ^^A FIXME: What is the following code for? Is it for people who want to use ucs.sty with Plain TeX
% ^^A or ConTeXt?
\catcode`\@11
\ifx\AddToHook\@undefined\else
\AddToHook{package/hyperref/after}{%
\def\HyPsd@expand@utfviii{%
\count@"C2
\@tempcnta"E0
\def\UTFviii@tmp{%
\expandafter\def\expandafter~\expandafter####\expandafter1\expandafter{~{####1}}%
}%
\UTFviii@loop
\count@"E0
\@tempcnta"F0
\def\UTFviii@tmp{%
\expandafter\def\expandafter~\expandafter####\expandafter1\expandafter####\expandafter2\expandafter{~{####1}{####2}}%
}%
\UTFviii@loop
\count@"F0
\@tempcnta"F5
\def\UTFviii@tmp{%
\expandafter\def\expandafter~\expandafter####\expandafter1\expandafter####\expandafter2\expandafter####\expandafter3\expandafter{~{####1}{####2}{####3}}%
}%
\UTFviii@loop
}
}
\fi
\ifx\@gobble\undefined\def\@gobble#1{}\fi
\ifx\@gobbletwo\undefined\def\@gobbletwo#1#2{}\fi
\ifx\@gobblethree\undefined\def\@gobblethree#1#2#3{}\fi
\ifx\@gobblefour\undefined\def\@gobblefour#1#2#3#4{}\fi
\ifx\@firstofone\undefined\def\@firstofone#1{#1}\fi
\ifx\@tempcnta\undefined\csname newcount\endcsname\@tempcnta\fi
\ifx\@tempcntb\undefined\csname newcount\endcsname\@tempcntb\fi
\ifx\@testopt\undefined
\def\@testopt#1#2{%
\@ifnextchar[{#1}{#1[{#2}]}}\fi
\ifx\@protected@testopt\undefined\def\@protected@testopt{\expandafter\@testopt\@gobble}\fi
\let\@let@token\relax
% ^^A FIXME: The previous line was suggested on
% ^^A
% ^^A <http://tex.stackexchange.com/questions/113261/conflict-between-ifxetex-and-ucs-under-pdflatex-xelatex-why/113278#113278> ,
% ^^A
% ^^A where it says the following:
% ^^A
% ^^A [The code for optionally defining \@ifnextchar] fails in the case where the
% ^^A immediately preceding use of \@let@token was by \newif. That's because it is the
% ^^A \let to \iffalse, meaning that the conditional is unbalanced and everything 'runs
% ^^A away'.
\ifx\@ifnextchar\undefined
\def\@ifnextchar#1#2#3{%
\let\reserved@d=#1%
\def\reserved@a{#2}%
\def\reserved@b{#3}%
\futurelet\@let@token\@ifnch}\fi
\ifx\@ifnch\undefined
\def\@ifnch{%
\ifx\@let@token\@sptoken
\let\reserved@c\@xifnch
\else
\ifx\@let@token\reserved@d
\let\reserved@c\reserved@a
\else
\let\reserved@c\reserved@b
\fi
\fi
\reserved@c}\fi
\ifx\@inputcheck\undefined\newread\@inputcheck\fi
\ifx\IfFileExists\undefined
\long\def\IfFileExists#1#2#3{%
\openin\@inputcheck#1 %SPACE
\ifeof\@inputcheck\def\reserved@a{#3}%
\else\closein\@inputcheck\def\reserved@a{#2}%
\fi
\reserved@a}%
\fi
\ifx\InputIfFileExists\undefined
\long\def\InputIfFileExists#1#2{%
\IfFileExists{#1}{#2\input #1 }}
\fi
\ifx\protect\undefined\let\protect\relax\fi
\ifx\@typeset@protect\undefined\let\@typeset@protect\relax\fi
\ifx\IeC\undefined\def\IeC{\ifx\protect\@typeset@protect
\expandafter\@firstofone\else\noexpand\IeC\fi}\fi
% \end{macrocode}
%
%^^A The following macros are defined using |\providecommand| before the package
%^^A option processing, because they are needed during the processing.
%
% \begin{macro}{\XDeclareUnicodeOption}
% \args{\marg{pkg}\marg{name}\marg{activate}^^A
% \marg{on}\marg{off}}
% \begin{macro}{\DeclareUnicodeOption}
% \args{\oarg{pkg}\marg{name}}
% Declare an unicode option, i.\,e.~the command
% \texttt{\bslash ifUnicodeOption\meta{name}} to
% test if \meta{name} is activated, further the commands
% \texttt{\bslash @unicode@option@\meta{name}} and
% \texttt{\bslash @unicode@option@no\meta{name}} to switch the option
% on and off, which take a priority as argument (it is ignored in
% case of the deactivation command).
% If the optional argument \meta{pkg} is specified and not empty,
% the option is
% automatically activated, if package \meta{pkg} is loaded.
%
% If \marg{activate} is code
% which is executed when the option is first used.
%
% \marg{on} and \marg{off} are executed every time the option is switched
% on resp.~off.
%
% The activation and deactivation commands call |\uni@activate@option| at their
% first call, which then sets their normal behaviour. This is done to ensure,
% that on the initial call we can mark this option as ``in use'', so we
% can do optimizations when loading data.
% \begin{macrocode}
\def\unicode@knownoptions{}
\def\XDeclareUnicodeOption#1#2#3#4#5{%
\expandafter\let\csname ifUnicodeOption#2\endcsname\iffalse
\expandafter\def\csname UnicodeOption#2true%
\expandafter\endcsname\expandafter{%
\expandafter\let\csname ifUnicodeOption#2\endcsname\iftrue}%
\expandafter\def\csname UnicodeOption#2false%
\expandafter\endcsname\expandafter{%
\expandafter\let\csname ifUnicodeOption#2\endcsname\iffalse}%
\expandafter\def\csname @unicode@option@#2\endcsname{%
#3\uni@activate@option{#2}{}{#4}{#5}}%
\expandafter\def\csname @unicode@option@no#2\endcsname{%
#3\uni@activate@option{#2}{no}{#4}{#5}}%
\ifx~#1~\else\LinkUnicodeOptionToPkg{#2}{#1}\fi
% \end{macrocode}
% Keep a list of known options
% \begin{macrocode}
\let\uc@tempa\\\let\\\relax
\edef\unicode@knownoptions{\\{#2}\unicode@knownoptions}%
\let\\\uc@tempa
}%
\let\uc@newcommand\def
\uc@newcommand\DeclareUnicodeOption{\@protected@testopt\DeclareUnicodeOption\DeclareUnicodeOption@{}}
\uc@newcommand\DeclareUnicodeOption@[#1]#2{%
\XDeclareUnicodeOption{#1}{#2}{}{}{}}%
% \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\uc@errormsg}
% \tobe
% \begin{macrocode}
\uc@newcommand\uc@errormsg#1#2{%
\ifx\PackageError\undefined
{\newlinechar`\^^J\def\MessageBreak{^^J}%
\errhelp{#2}\errmessage{Package ucs: #1}}%
\else
\PackageError{ucs}{#1}{#2}%
\fi
}%
\uc@newcommand\uc@warnmsg#1{%
\ifx\PackageWarning\undefined
{\newlinechar`\^^J\def\MessageBreak{^^J}%
\message{Package ucs: #1\MessageBreak}}%
\else
\PackageWarning{ucs}{#1}%
\fi
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\uni@activate@option}
% \args{\marg{option}\marg{no}\marg{on}\marg{off}\marg{prio}}
% This sets the \texttt{\bslash @unicode@option@\meta{name}} and
% \texttt{\bslash @unicode@option@no\meta{name}} commands
% to their normal behavior (setting and unsetting the option),
% and then executes the first (in case \meta{no} is empty) or
% the latter (in case \meta{no} is |no|) with \meta{prio} as
% argument.
%
% \marg{on} and \marg{off} are executed when the option is
% swtiched on resp.~off.
% \begin{macrocode}
\def\uni@activate@option#1#2#3#4#5{%
\ifx\uni@dataloaded\undefined
\global\expandafter\def\csname @unicode@option@#1\endcsname##1{%
\csname UnicodeOption#1true\endcsname
\expandafter\def\csname uo-prio-#1\endcsname{##1}#3}%
\global\expandafter\def\csname @unicode@option@no#1\endcsname##1%
{\csname UnicodeOption#1false\endcsname#4}%
% \end{macrocode}
% Mark this option as in use
\global\expandafter\let\csname uni@active@#1\endcsname1%
% \begin{macrocode}
\csname @unicode@option@#2#1\endcsname{#5}\else
\uc@errormsg{Option #1 must be activated or deactivated %SPACE
at least once in the preamble before using it in the document}{%
For optimization causes I must know all %SPACE
options before loading any unicode data.\MessageBreak
Try e.g. #1 or no#1 as package option to ucs.}\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LinkUnicodeOptionToPkg}
% \args{\marg{option}\marg{pkg}}
% Links the option \meta{option} to package \meta{pkg}, i.\,e.~if \meta{pkg} is
% loaded, \meta{option} is set.
% This mechanism is deprecated!
% \begin{macrocode}
\def\LinkUnicodeOptionToPkg#1#2{%
\AtBeginDocument{\@ifpackageloaded{#2}{\SetUnicodeOption{#1}}{}}}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\SetUnicodeOption}
% \args{\oarg{prio}\marg{option}}
% Activates the unicode option \meta{option}, or disables it, if
% prefixed by |no|. The option get the priority \meta{prio} if activated,
% whereby the default ist 100.
% \begin{macrocode}
\uc@newcommand\SetUnicodeOption{\@protected@testopt\SetUnicodeOption\SetUnicodeOption@{100}}
\uc@newcommand\SetUnicodeOption@[#1]#2{%
\edef\uc@temp@a{@unicode@option@#2}%
\expandafter\ifx\csname\uc@temp@a\endcsname\relax
\PackageError{ucs}{Unknown unicode option #2}{}%
\else
\csname\uc@temp@a\endcsname{#1}%
\fi}
% \end{macrocode}
% \end{macro}
%
% ^^A FIXME: We should update the date of ucs.sty even if the file ucs.sty has not changed, but the
% ^^A character mappings have. Otherwise, we cannot specify a complience level by adding a
% ^^A date to \usepackage{ucs} or \RequirePackage{ucs}.
% Loads the global definitions of the unicode data. This is done so early,
% because we need the option definitions.
% \begin{macrocode}
\ifx\@@input\undefined\input uni-global.def \else\input{uni-global.def}\fi
% \end{macrocode}
% \SpecialMainOptionIndex{fasterrors}
% If this option is set, we don't include the characters name in error
% messages, which runs much faster.
% \begin{macrocode}
\DeclareUnicodeOption{fasterrors}
% \end{macrocode}
% \SpecialMainOptionIndex{warnunknown}
% If this option is set, errors about unknown characters become warnings.
% \begin{macrocode}
\DeclareUnicodeOption{warnunknown}
% \end{macrocode}
% \SpecialMainOptionIndex{graphics}
% If this option is set, we try to download and include
% GIFs from |unicode.org| to replace missing characters.
% \begin{macrocode}
\DeclareUnicodeOption{graphics}
% \end{macrocode}
% \SpecialMainOptionIndex{savemem}
% If this option is set, we try several memory saving optimizations,
% which slow down the operation.
% \begin{macrocode}
\DeclareUnicodeOption{savemem}
% \end{macrocode}
% \SpecialMainOptionIndex{document}
% This option is reserved for manual declarations in the document
% (using
% |\DeclareUnicodeCharacter| and |\DeclareUnicodeCharacterAsOptional|).
% It is activated by default.
% \begin{macrocode}
\DeclareUnicodeOption{document}
\SetUnicodeOption[1000]{document}
% \end{macrocode}
% \SpecialMainOptionIndex{default}
% This option contains all normal characters. It is activated by default,
% but with priority 0, i.e.~all other options take precedence.
% \begin{macrocode}
\DeclareUnicodeOption{default}
\SetUnicodeOption[0]{default}
% \end{macrocode}
% \SpecialMainOptionIndex{combine}
% This option switches character combination on and off
% (see section \ref{combining}). Switching it off also flushes the
% combination buffer.
% \begin{macrocode}
\XDeclareUnicodeOption{}{combine}{}{%
\let\uc@cmb\empty}{%
\ifx\unicodecombine\undefined\else\unicodecombine\fi
\def\uc@cmb{\uc@warn@nocombine}}%
\ifx\AtBeginDocument\undefined\else
\AtEndDocument{\unicodecombine}\fi
\SetUnicodeOption{nocombine}%
% \end{macrocode}
% \begin{macro}{\uc@cmb}
% This is called by all combining characters to give a warning, if character
% combination is not enabled. Its default value is to give a warning, it is
% redefined to |\empty|, when character combination is enabled.
% \begin{macrocode}
\def\uc@cmb{\uc@warn@nocombine}%
% \end{macrocode}
% \end{macro}
% The usual option processing stuff.
% \begin{macrocode}
\ifx\DeclareOption\undefined\else
\DeclareOption{showmagickern}{\def\uc@magic@glue{6805678}}%
\DeclareOption{hyperref}{\AtEndOfPackage{\RequirePackage{ucshyper}}}%
\DeclareOption*{\SetUnicodeOption{\CurrentOption}}\ProcessOptions*
\fi
% \end{macrocode}
% Patch some fontencodings.
% \begin{macrocode}
\ifx\AtBeginDocument\undefined
\uc@warnmsg{Not loading ucsencs.def automatically.\MessageBreak
Please load it after initializing fontencodings}%
\else
\AtBeginDocument{\input{ucsencs.def}}\fi
% \end{macrocode}
%
% If the option |graphics| is set, we need to load the package |graphicx|.
% \begin{macrocode}
\AtBeginDocument{\ifUnicodeOptiongraphics\RequirePackage{graphicx}\fi}%
% \end{macrocode}
%
%
% \begin{macro}{\unicode@numtohex}
% \args{\marg{target}\marg{number}\marg{len}}
% Puts the hex representation of \meta{number} into the macro
% \meta{target} with at least \meta{len}
% digits. \meta{number} can be any valid \TeX-number. The result contains
% uppercase letters. The assignment to \meta{target} is global.
% \begin{macrocode}
\uc@newcommand\unicode@numtohex{\protect\unicode@numtohex@}%
\uc@newcommand\unicode@numtohex@#1#2#3{%
{%\let\empty\relax\relax
%\ifx\empty\relax\def\empty{}%
\count255=#2\relax\gdef#1{}%
\count252=#3%
\loop
\count253=\count252\advance\count253by\count255\relax
\ifnum\count253>0%
\ifnum\count252>0\advance\count252by-1\relax\fi
\count254=\count255%
\divide\count255by16%
\multiply\count255by16%
\advance\count254by-\count255%
\xdef#1{\ifcase\count254 0\or1\or2\or3\or4\or5\or6\or7\or
8\or9\or A\or B\or C\or D\or E\or F\fi#1}%
\divide\count255by16\relax
\repeat
%\else
% \def#1{dec:#2}%
%\fi
}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\uc@spc}
% Same meaning as |\space|, but |\space| is redefined in some contexts (e.g.
% in a bookmark in hyperref with option |pdftex|).
% \begin{macrocode}
\let\uc@spc\space
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\uc@secondtry}
% If data is loaded to typeset a given character, its code position
% is saved herein,
% so when the character is called again, endless recursion in case of unfixable
% errors can be avoided using the information in |\uc@secondtry|
% \begin{macrocode}
\newcount\uc@secondtry
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\unicode@invalid}
% Expands into \LaTeX-Code, which is to be inserted for an unknown
% unicode character. The character number is given as argument.
% \begin{macrocode}
\uc@newcommand\unicode@invalid#1{%
\unicode@combine%
% \end{macrocode}
% If use of GIFs is activated, begin a group,\dots
% \begin{macrocode}
\ifUnicodeOptiongraphics{%
% \end{macrocode}
% \dots calculate URL without |http://| and trailing |.gif|,
% save it to |\uc@temp@c|
% \begin{macrocode}
\ifx\unicode@graphicsdir\undefined
\def\unicode@graphicsdir{ucs-glyphs}\fi
\ifx\unicode@graphicscmd\undefined
\def\unicode@graphicscmd{ucs-getglyph \hex\space \dec\space \path\space}\fi
\unicode@numtohex\hex{#1}4%
\count255=#1\relax
\divide\count255 by256\relax
\unicode@numtohex\uc@temp@b{\count255}2%
\edef\path{\unicode@graphicsdir/\uc@temp@b/U\hex.ps}%
\edef\dec{\number#1}%
% \end{macrocode}
% Test if we already have that image (as PS)
% \begin{macrocode}
\IfFileExists{\uc@temp@c}{}{%
% \end{macrocode}
% otherwise run shell commands for download and conversion
% \begin{macrocode}
\typeout{Running: \unicode@graphicscmd}%
\immediate\write18{\unicode@graphicscmd}%
}%
% \end{macrocode}
% Try if we have the file now
% \begin{macrocode}
\IfFileExists{\path}{%
% \end{macrocode}
% then include it
% \begin{macrocode}
\setbox255=\hbox{X}%
\edef\uc@temp@b{\begingroup\noexpand\uni@resetcatcodes
\noexpand\includegraphics[height=\the\ht255, trim=0 22.5 0 17.5]%
{\path}%
\noexpand\ProvidesFile{U\hex.ps}%
[Downloaded glyph for U+\hex]%
\endgroup}%
\typeout{\meaning\uc@temp@b}%
\expandafter\unicodevirtual\expandafter{\uc@temp@b}%
}{%
% \end{macrocode}
% otherwise we give a warning
% \begin{macrocode}
\PackageWarning{ucs}{File \uc@temp@d\uc@[email protected] %SPACE
not found.\MessageBreak
Use\MessageBreak
\space\space\space\space\unicode@graphicscmd\MessageBreak
or start latex with option -shell-escape\MessageBreak
if you have not already done so.}%
% \end{macrocode}
% and use the standard glyph for unknown characters
% \begin{macrocode}
\unicodevirtual{\unicode@invalidglyph{#1}}}}\else
% \end{macrocode}
% In case we don't want to use GIFs, simple include the standard glyph for
% invalid characters
% \begin{macrocode}
\unicodevirtual{\unicode@invalidglyph{#1}}\fi}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\unicode@invalidglyph}
% This is macro creates the glyph to insert for an unknown character, if
% everything else fails (see |\unicode@invalid|). The character code for
% the substituted character is given in the first argument.
% \begin{macrocode}
\uc@newcommand\unicode@invalidglyph#1{%
{\unicode@numtohex\uc@temp@d{#1}4%
\fontencoding{OT1}\texttt{[U+\uc@temp@d]}}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\uni@char}
% \args{\marg{code}}
% Expands into the \LaTeX-macro for unicode character \meta{code}.
% Loads the corresponding \texttt{uni-\dots.def}-file if necessary.
% \begin{macrocode}
\uc@newcommand\uni@char#1{%
\ucs@protected@unichar\iftrue
\expandafter\ifx\csname u-\number#1-h/o\endcsname\relax
% \end{macrocode}
% If the character is not defined yet, load it.
% \begin{macrocode}
\begingroup
% In case \let is not executed, this (until ===) expands
% to \let\relax\relax,
% otherwise we have \let\uc@notloaderr\@gobble
% Number of \empty's must equal number of args of \uc@char@notloaded
\let\uc@notloaderr\@gobble\empty\@gobbletwo\relax\relax
% ===
\expandafter\endgroup
% If \let not executed: Warning is emitted (see |\uc@notloaderr|)
% otherwise: |\uc@char@notloaded| is called.
\uc@notloaderr{\number#1}\uc@char@notloaded{#1}%
\else
% \end{macrocode}
% If the character is loaded, run |\uc@checkopts|
% with the options of this character
% as first arg and the code position as second; this will
% display the character with
% the correct option.
% \begin{macrocode}
\expandafter\expandafter\expandafter\uc@checkopts
\expandafter\expandafter\expandafter
{\csname u-\number#1-h/o\endcsname}{#1}%
\fi
\else
\noexpand\unichar{#1}%
\fi