Debian Codegraph @

texmf-dist/source/generic/soul/soul.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: soul.dtx
4 % Version: 2026-03-06 v3.2
5 % Info: Permit use of UTF-8 characters in soul
6 %
7 % Copyright (C) 2007 Heiko Oberdiek
8 % Copyright (C) 2016-2026 Oberdiek Package Support Group
9 % https://github.com/ho-tex/soul/issues
10 %
11 % This work may be distributed and/or modified under the
12 % conditions of the LaTeX Project Public License, either
13 % version 1.3c of this license or (at your option) any later
14 % version. This version of this license is in
15 % https://www.latex-project.org/lppl/lppl-1-3c.txt
16 % and the latest version of this license is in
17 % https://www.latex-project.org/lppl.txt
18 % and version 1.3 or later is part of all distributions of
19 % LaTeX version 2005/12/01 or later.
20 %
21 % This work has the LPPL maintenance status "maintained".
22 %
23 % The Current Maintainers of this work are
24 % Heiko Oberdiek and the Oberdiek Package Support Group
25 % https://github.com/ho-tex/soul/issues
26 %
27 % The Base Interpreter refers to any `TeX-Format',
28 % because some files are installed in TDS:tex/generic//.
29 %
30 % This work consists of the main source file soul.dtx
31 % and the derived files
32 % soul.sty, soul.pdf, soul.ins,soulutf8.sty
33 % soulutf8-test1.tex, soulutf8-test2.tex, soulutf8-test3.tex,
34 % soulutf8-test4.tex, soulutf8-test5.tex.
35 %
36 % Distribution:
37 % CTAN:macros/latex/contrib/soul/soul.dtx
38 % CTAN:macros/latex/contrib/soul/soul.pdf
39 %
40 % Unpacking:
41 % tex soul.ins
42 %<*driver>
43 \documentclass{ltxdoc}
44 \usepackage{holtxdoc}[2011/11/22]
45 \begin{document}
46 \DocInput{soul.dtx}%
47 \end{document}
48 %</driver>
49 % \fi
50 %
51 % \title{The \xpackage{soul} package}
52 % \date{2026-03-06 v3.2}
53 % \author{Heiko Oberdiek\thanks
54 % {Please report any issues at \url{https://github.com/ho-tex/soul/issues}}}
55 %
56 % \maketitle
57 %
58 % \begin{abstract}
59 % This version is a merge of the original
60 % package \xpackage{soul} (version 2.5 which contains some small corrections compared to the
61 % version 2.4 from 2003)
62 % and the \xpackage{soulutf8} which added some support
63 % for UTF-8. Namely the input encodings \xfile{utf8.def}
64 % from package \xpackage{inputenc} and
65 % package \xpackage{ucs}'s \xfile{utf8x.def} are supported.
66 % The original \xpackage{soul} package has been renamed to \xpackage{soul-ori} and is still loaded.
67 % Its documentation is still relevant.
68 % \end{abstract}
69 %
70 % \tableofcontents
71 %
72 % \section{Documentation}
73 %
74 % This package \xpackage{soul} does not have own options and does not
75 % define new user commands.
76 % Any option is passed to package \xpackage{soul-ori} \cite{soul}
77 % that is loaded first.
78 % Then some internal macros of \xpackage{soul-ori} are redefined to add
79 % support for UTF-8.
80 % The following input encodings are supported:
81 % \begin{quote}
82 % \begin{tabular}{@{}lll@{}}
83 % \texttt{utf8} & \LaTeX\ base &
84 % \xfile{TDS:tex/latex/base/utf8.def} \cite{utf8}\\
85 % \texttt{utf8x} & Package \xpackage{ucs} &
86 % \xfile{TDS:tex/latex/ucs/utf8x.def} \cite{ucs}\\
87 % \end{tabular}
88 % \end{quote}
89 % UTF-8 byte sequences are added as token group to a word, even
90 % if these UTF-8 characters are some kind of hyphen or space.
91 % As exception the following three Unicode characters are handled specially:
92 % \begin{quote}
93 % \begin{tabular}{lll}
94 % Slot & Name & Action\\
95 % \hline
96 % \texttt{U+00A0} & NO-BREAK SPACE & like |~|\\
97 % \texttt{U+2013} & EN DASH & |--|\\
98 % \texttt{U+2014} & EM DASH & |---|
99 % \end{tabular}
100 %
101 % \subsection{Patch}
102 %
103 % Also package \xpackage{soul} tries to patch package \xpackage{soul-ori}
104 % to improve its behaviour:
105 % \begin{itemize}
106 % \item
107 % A problem with additional levels of curly braces is fixed.
108 % As advantage more implicit kernings are detected.
109 % However, the result may be incompatible with the
110 % original behaviour of package \xpackage{soul-ori} because
111 % of these respected implicit kernings.
112 % \item
113 % \eTeX\ , especially \cs{unexpanded} is supported.
114 % This allows a better protection of token groups
115 % (|\mbox{|\dots|}|, math, \dots).
116 % \end{itemize}
117 % \end{quote}
118 %
119 % \subsection{Future}
120 %
121 % Currently package \xpackage{soul-ori} does not seem to be
122 % maintained. Nevertheless if there will be a new version that
123 % adds support for UTF-8, then this package may become
124 % obsolete.
125 %
126 % \StopEventually{
127 % }
128 %
129 % \section{Implementation}
130 % \begin{macrocode}
131 %<*soulutf8>
132 \NeedsTeXFormat{LaTeX2e}
133 \ProvidesPackage{soulutf8}%
134 [2026-03-06 v3.2 Permit use of UTF-8 characters in soul (HO)]%
135 \PackageWarning{soulutf8}
136 {This package is obsolete,\MessageBreak
137 use the soul package directly. \MessageBreak
138 }{}%
139 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{soul}}%
140 \ProcessOptions\relax
141 \RequirePackage{soul}
142 %</soulutf8>
143 % \end{macrocode}
144 % \begin{macrocode}
145 %<*package>
146 % \end{macrocode}
147 %
148 % \subsection{Reload check and package identification}
149 % Reload check, especially if the package is not used with \LaTeX.
150 % \begin{macrocode}
151 \begingroup\catcode61\catcode48\catcode32=10\relax%
152 \catcode13=5 % ^^M
153 \endlinechar=13 %
154 \catcode35=6 % #
155 \catcode39=12 % '
156 \catcode44=12 % ,
157 \catcode45=12 % -
158 \catcode46=12 % .
159 \catcode58=12 % :
160 \catcode64=11 % @
161 \catcode123=1 % {
162 \catcode125=2 % }
163 \expandafter\let\expandafter\x\csname [email protected]\endcsname
164 \ifx\x\relax % plain-TeX, first loading
165 \else
166 \def\empty{}%
167 \ifx\x\empty % LaTeX, first loading,
168 % variable is initialized, but \ProvidesPackage not yet seen
169 \else
170 \expandafter\ifx\csname PackageInfo\endcsname\relax
171 \def\x#1#2{%
172 \immediate\write-1{Package #1 Info: #2.}%
173 }%
174 \else
175 \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
176 \fi
177 \x{soul}{The package is already loaded}%
178 \aftergroup\endinput
179 \fi
180 \fi
181 \endgroup%
182 % \end{macrocode}
183 % Package identification:
184 % \begin{macrocode}
185 \begingroup\catcode61\catcode48\catcode32=10\relax%
186 \catcode13=5 % ^^M
187 \endlinechar=13 %
188 \catcode35=6 % #
189 \catcode39=12 % '
190 \catcode40=12 % (
191 \catcode41=12 % )
192 \catcode44=12 % ,
193 \catcode45=12 % -
194 \catcode46=12 % .
195 \catcode47=12 % /
196 \catcode58=12 % :
197 \catcode64=11 % @
198 \catcode91=12 % [
199 \catcode93=12 % ]
200 \catcode123=1 % {
201 \catcode125=2 % }
202 \expandafter\ifx\csname ProvidesPackage\endcsname\relax
203 \def\x#1#2#3[#4]{\endgroup
204 \immediate\write-1{Package: #3 #4}%
205 \xdef#1{#4}%
206 }%
207 \else
208 \def\x#1#2[#3]{\endgroup
209 #2[{#3}]%
210 \ifx#1\@undefined
211 \xdef#1{#3}%
212 \fi
213 \ifx#1\relax
214 \xdef#1{#3}%
215 \fi
216 }%
217 \fi
218 \expandafter\x\csname [email protected]\endcsname
219 \ProvidesPackage{soul}%
220 [2026-03-06 v3.2 Permit use of UTF-8 characters in soul (HO)]%
221 % \end{macrocode}
222 %
223 % \subsection{Catcodes}
224 %
225 % \begin{macrocode}
226 \begingroup\catcode61\catcode48\catcode32=10\relax%
227 \catcode13=5 % ^^M
228 \endlinechar=13 %
229 \catcode123=1 % {
230 \catcode125=2 % }
231 \catcode64=11 % @
232 \def\x{\endgroup
233 \expandafter\edef\csname SOuL@AtEnd\endcsname{%
234 \endlinechar=\the\endlinechar\relax
235 \catcode13=\the\catcode13\relax
236 \catcode32=\the\catcode32\relax
237 \catcode35=\the\catcode35\relax
238 \catcode61=\the\catcode61\relax
239 \catcode64=\the\catcode64\relax
240 \catcode123=\the\catcode123\relax
241 \catcode125=\the\catcode125\relax
242 }%
243 }%
244 \x\catcode61\catcode48\catcode32=10\relax%
245 \catcode13=5 % ^^M
246 \endlinechar=13 %
247 \catcode35=6 % #
248 \catcode64=11 % @
249 \catcode123=1 % {
250 \catcode125=2 % }
251 \def\TMP@EnsureCode#1#2{%
252 \edef\SOuL@AtEnd{%
253 \SOuL@AtEnd
254 \catcode#1=\the\catcode#1\relax
255 }%
256 \catcode#1=#2\relax
257 }
258 \TMP@EnsureCode{10}{12}% ^^J
259 \TMP@EnsureCode{33}{12}% !
260 \TMP@EnsureCode{34}{12}% "
261 \TMP@EnsureCode{36}{3}% $
262 \TMP@EnsureCode{39}{12}% '
263 \TMP@EnsureCode{40}{12}% (
264 \TMP@EnsureCode{41}{12}% )
265 \TMP@EnsureCode{42}{12}% *
266 \TMP@EnsureCode{43}{12}% +
267 \TMP@EnsureCode{44}{12}% ,
268 \TMP@EnsureCode{45}{12}% -
269 \TMP@EnsureCode{46}{12}% .
270 \TMP@EnsureCode{47}{12}% /
271 \TMP@EnsureCode{58}{12}% :
272 \TMP@EnsureCode{60}{12}% <
273 \TMP@EnsureCode{62}{12}% >
274 \TMP@EnsureCode{91}{12}% [
275 \TMP@EnsureCode{93}{12}% ]
276 \TMP@EnsureCode{94}{7}% ^
277 \TMP@EnsureCode{96}{12}% `
278 \TMP@EnsureCode{126}\active % ~
279 \TMP@EnsureCode{128}{12}% ^^80
280 \TMP@EnsureCode{147}{12}% ^^93
281 \TMP@EnsureCode{148}{12}% ^^94
282 \TMP@EnsureCode{160}{12}% ^^a0
283 \TMP@EnsureCode{194}{12}% ^^c2
284 \TMP@EnsureCode{226}{12}% ^^e2
285 \edef\SOuL@AtEnd{\SOuL@AtEnd\noexpand\endinput}
286 % \end{macrocode}
287 %
288 % \subsection{Loading packages}
289 %
290 % Package \xpackage{soul-ori} uses \cs{documentclass} to detect \LaTeX.
291 % \begin{macrocode}
292 \ifx\documentclass\@undefined
293 % \end{macrocode}
294 %
295 % \subsubsection{\plainTeX}
296 %
297 % First we check, whether package \xpackage{soul-ori} is already loaded.
298 % \begin{macrocode}
299 \expandafter\ifx\csname SOUL@\endcsname\relax
300 % \end{macrocode}
301 % In case of \plainTeX\ package \xpackage{soul-ori} defines some
302 % macros in a simple manner that will break the definitions of
303 % \xfile{miniltx.tex}, for example. Therefore these macros
304 % are first saved and restored afterwards.
305 % \begin{macrocode}
306 \let\SOuL@orgDeclareRobustCommand\DeclareRobustCommand
307 \let\SOuL@orgnewcommand \newcommand
308 \let\SOuL@orgDeclareOption \DeclareOption
309 \let\SOuL@orgPackageError \PackageError
310 \def\SOuL@restorelatexcmds{%
311 \let\DeclareRobustCommand\SOuL@orgDeclareRobustCommand
312 \let\newcommand \SOuL@orgnewcommand
313 \let\DeclareOption \SOuL@orgDeclareOption
314 \let\PackageError \SOuL@orgPackageError
315 }%
316 \input soul-ori.sty\relax
317 \SOuL@restorelatexcmds
318 \fi
319 % \end{macrocode}
320 % \begin{macro}{\SOUL@error}
321 % Package \xpackage{soul-ori}'s use of \cs{PackageError} is replaced
322 % by \cs{@PackageError} of package \xpackage{infwarerr}.
323 % \begin{macrocode}
324 \input infwarerr.sty\relax
325 \let\SOuL@orgSOUL@error\SOUL@error
326 \def\SOUL@error{%
327 \begingroup
328 \let\PackageError\@PackageError
329 \SOuL@orgSOUL@error
330 \endgroup
331 }%
332 % \end{macrocode}
333 % \end{macro}
334 % \begin{macrocode}
335 \input etexcmds.sty\relax
336 % \end{macrocode}
337 % \begin{macro}{\@onelevel@sanitize}
338 % Define \LaTeX's \cs{@onelevel@sanitize} if not already available.
339 % \begin{macrocode}
340 \expandafter\ifx\csname @onelevel@sanitize\endcsname\relax
341 \def\@onelevel@sanitize#1{%
342 \edef#1{%
343 \expandafter\strip@prefix\meaning#1%
344 }%
345 }%
346 % \end{macrocode}
347 % \end{macro}
348 % \begin{macro}{\strip@prefix}
349 % \begin{macrocode}
350 \def\strip@prefix#1>{}%
351 % \end{macrocode}
352 % \end{macro}
353 % \begin{macrocode}
354 \fi
355 \else
356 % \end{macrocode}
357 %
358 % \subsubsection{\LaTeX}
359 % \begin{macrocode}
360 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{soul-ori}}%
361 \ProcessOptions\relax
362 \RequirePackage{soul-ori}[2023-02-18]%
363 \RequirePackage{infwarerr}[2019/12/03]%
364 \RequirePackage{etexcmds}[2019/12/15]%
365 \fi
366 % \end{macrocode}
367 %
368 % \subsubsection{\eTeX}
369 %
370 % In \plainTeX\ command \cs{+} is an \emph{outer} macro.
371 % Therefore numbers are used to avoid problems.
372 % \begin{macrocode}
373 \ifetex@unexpanded
374 \catcode33=14 % '!': comment
375 \catcode43=9 % '+': ignore
376 \else
377 \catcode33=9 % '!': ignore
378 \catcode43=14 % '+': comment
379 \fi
380 % \end{macrocode}
381 %
382 % \subsection{Macro for redefinitions}
383 %
384 % \begin{macro}{\SOuL@redefine}
385 % \begin{macrocode}
386 \def\SOuL@redefine#1{%
387 \begingroup
388 \def\SOuL@cmd{#1}%
389 \afterassignment\SOuL@cmdcheck
390 \def\SOuL@temp
391 }
392 % \end{macrocode}
393 % \end{macro}
394 % \begin{macro}{\SOuL@cmdcheck}
395 % \begin{macrocode}
396 \def\SOuL@cmdcheck{%
397 \expandafter\ifx\SOuL@cmd\SOuL@temp
398 \else
399 \edef\SOuL@temp*{\expandafter\string\SOuL@cmd}%
400 \@PackageWarningNoLine{soul}{%
401 Command \SOuL@temp* has changed.\MessageBreak
402 Supported versions of package `soul-ori': 2021/12/14.\MessageBreak
403 Depending on the unknown changes the redefinition\MessageBreak
404 of \SOuL@temp* may not behave correctly%
405 }%
406 \fi
407 \expandafter\endgroup
408 \expandafter\def\SOuL@cmd
409 }
410 % \end{macrocode}
411 % \end{macro}
412 %
413 % \subsection{Redefinition of \cs{SOUL@eval}}
414 %
415 % \begin{macro}{\SOUL@eval}
416 % Macro \cs{SOUL@eval} is redefined to add detection of
417 % the first byte of a UTF-8 sequence. Because \cs{SOUL@eval}
418 % is overwritten, a warning is issued, if the contents of
419 % \cs{SOUL@eval} is not as expected.
420 % \begin{macrocode}
421 \SOuL@redefine\SOUL@eval{%
422 % \end{macrocode}
423 % First the expected definition.
424 % \begin{macrocode}
425 \def\SOUL@n*##1{\SOUL@scan}%
426 \if\noexpand\SOUL@@\SOUL@spc
427 \else
428 \SOUL@ignorespacesfalse
429 \fi
430 \ifnum\SOUL@minus=\thr@@
431 \SOUL@flushminus
432 \else\ifnum\SOUL@comma=\tw@
433 \SOUL@flushcomma
434 \else\ifnum\SOUL@apo=\tw@
435 \SOUL@flushapo
436 \else\ifnum\SOUL@grave=\tw@
437 \SOUL@flushgrave
438 \fi\fi\fi\fi
439 \ifx\SOUL@@-\else\SOUL@flushminus\fi
440 \ifx\SOUL@@,\else\SOUL@flushcomma\fi
441 \ifx\SOUL@@'\else\SOUL@flushapo\fi
442 \ifx\SOUL@@`\else\SOUL@flushgrave\fi
443 \ifx\SOUL@@-%
444 \advance\SOUL@minus\@ne
445 \else\ifx\SOUL@@,%
446 \advance\SOUL@comma\@ne
447 \else\ifx\SOUL@@'%
448 \advance\SOUL@apo\@ne
449 \else\ifx\SOUL@@`%
450 \advance\SOUL@grave\@ne
451 \else
452 \SOUL@flushminus
453 \SOUL@flushcomma
454 \SOUL@flushapo
455 \SOUL@flushgrave
456 \ifx\SOUL@@\SOUL@stop
457 \def\SOUL@n*{%
458 \SOUL@doword
459 \SOUL@eventuallyexhyphen\null
460 }%
461 \else\ifx\SOUL@@\par
462 \def\SOUL@n*\par{\par\leavevmode\SOUL@scan}%
463 \else\if\noexpand\SOUL@@\SOUL@spc
464 \SOUL@doword
465 \SOUL@eventuallyexhyphen\null
466 \ifSOUL@ignorespaces
467 \else
468 \SOUL@everyspace{}%
469 \fi
470 \def\SOUL@n* {\SOUL@scan}%
471 \else\ifx\SOUL@@\\%
472 \SOUL@doword
473 \SOUL@eventuallyexhyphen\null
474 \SOUL@everyspace{\unskip\nobreak\hfil\break}%
475 \SOUL@ignorespacestrue
476 \else\ifx\SOUL@@~%
477 \SOUL@doword
478 \SOUL@eventuallyexhyphen\null
479 \SOUL@everyspace{\nobreak}%
480 \else\ifx\SOUL@@\slash
481 \SOUL@doword
482 \SOUL@eventuallyexhyphen{/}%
483 \SOUL@exhyphen{/}%
484 \else\ifx\SOUL@@\mbox
485 \def\SOUL@n*{\SOUL@addprotect}%
486 \else\ifx\SOUL@@\hbox
487 \def\SOUL@n*{\SOUL@addprotect}%
488 \else\ifx\SOUL@@\soulomit
489 \def\SOUL@n*\soulomit##1{%
490 \SOUL@doword
491 {\spaceskip\SOUL@spaceskip##1}%
492 \SOUL@scan
493 }%
494 \else\ifx\SOUL@@\break
495 \SOUL@doword
496 \break
497 \else\ifx\SOUL@@\linebreak
498 \SOUL@doword
499 \SOUL@everyspace{\linebreak}%
500 \else\ifcat\bgroup\noexpand\SOUL@@
501 \def\SOUL@n*{\SOUL@addgroup{}}%
502 \else\ifcat$\noexpand\SOUL@@
503 \def\SOUL@n*{\SOUL@addmath}%
504 \else
505 \def\SOUL@n*{\SOUL@dotoken}%
506 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
507 \fi\fi\fi\fi
508 \SOUL@n*%
509 }{%
510 % \end{macrocode}
511 % Now the redefined version follows.
512 % \begin{macrocode}
513 \def\SOUL@n*##1{\SOUL@scan}%
514 \if\noexpand\SOUL@@\SOUL@spc
515 \else
516 \SOUL@ignorespacesfalse
517 \fi
518 \ifnum\SOUL@minus=\thr@@
519 \SOUL@flushminus
520 \else\ifnum\SOUL@comma=\tw@
521 \SOUL@flushcomma
522 \else\ifnum\SOUL@apo=\tw@
523 \SOUL@flushapo
524 \else\ifnum\SOUL@grave=\tw@
525 \SOUL@flushgrave
526 \fi\fi\fi\fi
527 \ifx\SOUL@@-\else\SOUL@flushminus\fi
528 \ifx\SOUL@@,\else\SOUL@flushcomma\fi
529 \ifx\SOUL@@'\else\SOUL@flushapo\fi
530 \ifx\SOUL@@`\else\SOUL@flushgrave\fi
531 \ifx\SOUL@@-%
532 \advance\SOUL@minus\@ne
533 \else\ifx\SOUL@@,%
534 \advance\SOUL@comma\@ne
535 \else\ifx\SOUL@@'%
536 \advance\SOUL@apo\@ne
537 \else\ifx\SOUL@@`%
538 \advance\SOUL@grave\@ne
539 \else
540 \SOUL@flushminus
541 \SOUL@flushcomma
542 \SOUL@flushapo
543 \SOUL@flushgrave
544 \ifx\SOUL@@\SOUL@stop
545 \def\SOUL@n*{%
546 \SOUL@doword
547 \SOUL@eventuallyexhyphen\null
548 }%
549 \else\ifx\SOUL@@\par
550 \def\SOUL@n*\par{\par\leavevmode\SOUL@scan}%
551 \else\if\noexpand\SOUL@@\SOUL@spc
552 \SOUL@doword
553 \SOUL@eventuallyexhyphen\null
554 \ifSOUL@ignorespaces
555 \else
556 \SOUL@everyspace{}%
557 \fi
558 \def\SOUL@n* {\SOUL@scan}%
559 \else\ifx\SOUL@@\\%
560 \SOUL@doword
561 \SOUL@eventuallyexhyphen\null
562 \SOUL@everyspace{\unskip\nobreak\hfil\break}%
563 \SOUL@ignorespacestrue
564 \else\ifx\SOUL@@~%
565 \SOUL@doword
566 \SOUL@eventuallyexhyphen\null
567 \SOUL@everyspace{\nobreak}%
568 \else\ifx\SOUL@@\slash
569 \SOUL@doword
570 \SOUL@eventuallyexhyphen{/}%
571 \SOUL@exhyphen{/}%
572 \else\ifx\SOUL@@\mbox
573 \def\SOUL@n*{\SOUL@addprotect}%
574 \else\ifx\SOUL@@\hbox
575 \def\SOUL@n*{\SOUL@addprotect}%
576 \else\ifx\SOUL@@\soulomit
577 \def\SOUL@n*\soulomit##1{%
578 \SOUL@doword
579 {\spaceskip\SOUL@spaceskip##1}%
580 \SOUL@scan
581 }%
582 \else\ifx\SOUL@@\break
583 \SOUL@doword
584 \break
585 \else\ifx\SOUL@@\linebreak
586 \SOUL@doword
587 \SOUL@everyspace{\linebreak}%
588 \else\ifcat\bgroup\noexpand\SOUL@@
589 \def\SOUL@n*{\SOUL@addgroup{}}%
590 \else\ifcat$\noexpand\SOUL@@
591 \def\SOUL@n*{\SOUL@addmath}%
592 \else
593 % \end{macrocode}
594 % The current token is examined to detect the start of
595 % a UTF-8 sequence.
596 % \begin{macrocode}
597 \SOuL@analyzeutfviii
598 \ifcase\SOuL@octets
599 \SOuL@analyzeutfviiix
600 \fi
601 \ifcase\SOuL@octets
602 \def\SOUL@n*{\SOUL@dotoken}%
603 \or % 1
604 \or % 2
605 \def\SOUL@n*{\SOuL@addtwooctets}%
606 \or % 3
607 \def\SOUL@n*{\SOuL@addthreeoctets}%
608 \or % 4
609 \def\SOUL@n*{\SOuL@addfouroctets}%
610 \fi
611 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
612 \fi\fi\fi\fi
613 \SOUL@n*%
614 }
615 % \end{macrocode}
616 % \end{macro}
617 %
618 % \subsection{UTF-8 analysis}
619 %
620 % \subsubsection{Help strings}
621 %
622 % \begin{macrocode}
623 \def\SOuL@defsanitizedstring#1#2{%
624 \expandafter\def\csname SOuL@string#1\endcsname{#2}%
625 \expandafter\@onelevel@sanitize\csname SOuL@string#1\endcsname
626 }
627 \SOuL@defsanitizedstring{UTFviii}{UTFviii@}
628 \SOuL@defsanitizedstring{octets}{@octets}
629 \SOuL@defsanitizedstring{two}{two}
630 \SOuL@defsanitizedstring{three}{three}
631 \SOuL@defsanitizedstring{four}{four}
632 \SOuL@defsanitizedstring{macrocolon}{macro:}
633 \SOuL@defsanitizedstring{csnameu}{csname u8-}
634 \SOuL@defsanitizedstring{undeferr}{utf@viii@undeferr}
635 \def\SOuL@stringendash{^^e2^^80^^93}
636 \def\SOuL@stringemdash{^^e2^^80^^94}
637 \def\SOuL@stringnobreakspace{^^c2^^a0}
638 \edef\SOuL@charhash{\string #}
639 \edef\SOuL@chartwo{\string 2}
640 \edef\SOuL@charthree{\string 3}
641 \def\SOuL@empty{}
642 % \end{macrocode}
643 %
644 % \subsubsection{Support for \xfile{utf8.def}}
645 %
646 % \begin{macro}{\SOuL@analyzeutfviii}
647 % \begin{macrocode}
648 \begingroup
649 \edef\x{\endgroup
650 \def\noexpand\SOuL@analyzeutfviii{%
651 \noexpand\expandafter\noexpand\SOuL@checkutfviii
652 \noexpand\meaning\noexpand\SOUL@@
653 \SOuL@stringUTFviii\SOuL@stringoctets
654 \noexpand\@nil
655 }%
656 \def\noexpand\SOuL@checkutfviii
657 ##1\SOuL@stringUTFviii##2\SOuL@stringoctets##3\noexpand\@nil
658 }%
659 \x{%
660 \def\SOuL@temp{#2}%
661 \chardef\SOuL@octets=%
662 \ifx\SOuL@temp\SOuL@stringtwo
663 \tw@
664 \else\ifx\SOuL@temp\SOuL@stringthree
665 \thr@@
666 \else\ifx\SOuL@temp\SOuL@stringfour
667 4 %
668 \else
669 \z@
670 \fi\fi\fi
671 }
672 % \end{macrocode}
673 % \end{macro}
674 %
675 % \subsubsection{Support for \xfile{utf8x.def}}
676 %
677 % \begin{macro}{\SOuL@analyzeutfviiix}
678 % \begin{macrocode}
679 \begingroup
680 \edef\x{\endgroup
681 \def\noexpand\SOuL@analyzeutfviiix{%
682 \noexpand\expandafter\noexpand\SOuL@checkutfviiix
683 \noexpand\meaning\noexpand\SOUL@@
684 \SOuL@stringmacrocolon\SOuL@charhash1{}{}{}{}%
685 \SOuL@stringcsnameu\SOuL@stringundeferr
686 \noexpand\@nil
687 }%
688 % \end{macrocode}
689 % \end{macro}
690 % \begin{macro}{\SOuL@checkutfviiix}
691 % \begin{macrocode}
692 \def\noexpand\SOuL@checkutfviiix
693 ##1\SOuL@stringmacrocolon\SOuL@charhash1##2##3##4##5##6%
694 \SOuL@stringcsnameu##7\SOuL@stringundeferr##8\noexpand\@nil
695 }%
696 \x{%
697 \def\SOuL@temp{#7}%
698 \ifx\SOuL@temp\SOuL@empty
699 \chardef\SOuL@octets=\z@
700 \else
701 \def\SOuL@temp{#5}%
702 \ifx\SOuL@temp\SOuL@charthree
703 \chardef\SOuL@octets=4 %
704 \else
705 \def\SOuL@temp{#3}%
706 \ifx\SOuL@temp\SOuL@chartwo
707 \chardef\SOuL@octets=\thr@@
708 \else
709 \chardef\SOuL@octets=\tw@
710 \fi
711 \fi
712 \fi
713 }
714 % \end{macrocode}
715 % \end{macro}
716 %
717 % \subsection{Actions for UTF-8 sequences}
718 %
719 % \begin{macro}{\SOuL@addtwooctets}
720 % \begin{macrocode}
721 \def\SOuL@addtwooctets#1#2{%
722 \def\SOuL@temp{#1#2}%
723 \@onelevel@sanitize\SOuL@temp
724 \ifx\SOuL@temp\SOuL@stringnobreakspace
725 \SOUL@doword
726 \SOUL@eventuallyexhyphen\null
727 \SOUL@everyspace{\nobreak}%
728 \let\SOuL@next\SOUL@scan
729 \else
730 \def\SOuL@next{%
731 ! \SOUL@addtoken{{\noexpand#1\noexpand#2}}%
732 + \SOUL@addtoken{{\etex@unexpanded{#1#2}}}%
733 }%
734 \fi
735 \SOuL@next
736 }
737 % \end{macrocode}
738 % \end{macro}
739 % \begin{macro}{\SOuL@addthreeoctets}
740 % \begin{macrocode}
741 \def\SOuL@addthreeoctets#1#2#3{%
742 \def\SOuL@temp{#1#2#3}%
743 \@onelevel@sanitize\SOuL@temp
744 \ifx\SOuL@temp\SOuL@stringendash
745 \SOUL@doword
746 \SOUL@eventuallyexhyphen{-}%
747 \SOUL@exhyphen{--}%
748 \let\SOuL@next\SOUL@scan
749 \else
750 \ifx\SOuL@temp\SOuL@stringemdash
751 \SOUL@doword
752 \SOUL@eventuallyexhyphen{-}%
753 \SOUL@exhyphen{---}%
754 \let\SOuL@next\SOUL@scan
755 \else
756 \def\SOuL@next{%
757 ! \SOUL@addtoken{{\noexpand#1\noexpand#2\noexpand#3}}%
758 + \SOUL@addtoken{{\etex@unexpanded{#1#2#3}}}%
759 }%
760 \fi
761 \fi
762 \SOuL@next
763 }
764 % \end{macrocode}
765 % \end{macro}
766 % \begin{macro}{\SOuL@addfouroctets}
767 % \begin{macrocode}
768 \def\SOuL@addfouroctets#1#2#3#4{%
769 ! \SOUL@addtoken{{\noexpand#1\noexpand#2\noexpand#3\noexpand#4}}%
770 + \SOUL@addtoken{{\etex@unexpanded{#1#2#3#4}}}%
771 }
772 % \end{macrocode}
773 % \end{macro}
774 %
775 % \subsubsection{Redefinition of \cs{SOUL@splittoken}}
776 %
777 % \begin{macro}{\SOUL@splittoken}
778 % Macro \cs{SOUL@splittoken} separates the first token
779 % or token group from a word and redefines the word to contain
780 % the remaining tokens. However if the remaining tokens are
781 % a token group, then the curly braces will be removed and
782 % the token group is split by the next call of \cs{SOUL@splittoken}.
783 % The redefinition avoids the removal of curly braces around the
784 % remaining tokens.
785 % \begin{macrocode}
786 \SOuL@redefine\SOUL@splittoken#1#2\SOUL@stop{%
787 \global\SOUL@token={#1}%
788 \global\SOUL@word={#2}%
789 }#1{%
790 \global\SOUL@token={#1}%
791 \SOuL@remainingtoken\relax
792 }
793 % \end{macrocode}
794 % \end{macro}
795 % \begin{macro}{\SOuL@remainingtoken}
796 % \begin{macrocode}
797 \long\def\@gobble#1{}
798 \def\SOuL@remainingtoken#1\SOUL@stop{%
799 \global\SOUL@word=\expandafter{\@gobble#1}%
800 }
801 % \end{macrocode}
802 % \end{macro}
803 %
804 % \subsection{Patches}
805 %
806 % The fixed \cs{SOUL@splittoken} allows to remove the double
807 % sets of curly braces in other macros of package \xpackage{soul-ori}.
808 % The benefit is that implicit kernings are more often detected
809 % and fixes a bug in package \xpackage{soul-ori}. The disadvantage is
810 % incompatibility. The width of the resulting strings may change.
811 % \begin{macro}{\SOUL@flushcomma}
812 % \begin{macrocode}
813 \SOuL@redefine\SOUL@flushcomma{%
814 \ifcase\SOUL@comma
815 \or
816 \edef\x{\SOUL@word={\the\SOUL@word,}}\x
817 \or
818 \edef\x{\SOUL@word={\the\SOUL@word{{,,}}}}\x
819 \fi
820 \SOUL@comma\z@
821 }{%
822 \ifcase\SOUL@comma
823 \or
824 \edef\x{\SOUL@word={\the\SOUL@word,}}\x
825 \or
826 \edef\x{\SOUL@word={\the\SOUL@word{,,}}}\x
827 \fi
828 \SOUL@comma\z@
829 }
830 % \end{macrocode}
831 % \end{macro}
832 % \begin{macro}{\SOUL@flushapo}
833 % \begin{macrocode}
834 \SOuL@redefine\SOUL@flushapo{%
835 \ifcase\SOUL@apo
836 \or
837 \edef\x{\SOUL@word={\the\SOUL@word'}}\x
838 \or
839 \edef\x{\SOUL@word={\the\SOUL@word{{''}}}}\x
840 \fi
841 \SOUL@apo\z@
842 }{%
843 \ifcase\SOUL@apo
844 \or
845 \edef\x{\SOUL@word={\the\SOUL@word'}}\x
846 \or
847 \edef\x{\SOUL@word={\the\SOUL@word{''}}}\x
848 \fi
849 \SOUL@apo\z@
850 }
851 % \end{macrocode}
852 % \end{macro}
853 % \begin{macro}{\SOUL@flushgrave}
854 % \begin{macrocode}
855 \SOuL@redefine\SOUL@flushgrave{%
856 \ifcase\SOUL@grave
857 \or
858 \edef\x{\SOUL@word={\the\SOUL@word`}}\x
859 \or
860 \edef\x{\SOUL@word={\the\SOUL@word{{``}}}}\x
861 \fi
862 \SOUL@grave\z@
863 }{%
864 \ifcase\SOUL@grave
865 \or
866 \edef\x{\SOUL@word={\the\SOUL@word`}}\x
867 \or
868 \edef\x{\SOUL@word={\the\SOUL@word{``}}}\x
869 \fi
870 \SOUL@grave\z@
871 }
872 % \end{macrocode}
873 % \end{macro}
874 % \begin{macro}{\SOUL@addgroup}
875 % \begin{macrocode}
876 \SOuL@redefine\SOUL@addgroup#1#2{%
877 {%
878 \let\protect\noexpand
879 \edef\x{%
880 \global\SOUL@word={%
881 \the\SOUL@word
882 {{\noexpand#1#2}}%
883 }%
884 }%
885 \x
886 }%
887 \SOUL@scan
888 }#1#2{%
889 \begingroup
890 \let\protect\noexpand
891 \edef\x{\endgroup
892 \SOUL@word={%
893 \the\SOUL@word
894 ! {\noexpand#1{#2}}%
895 + {\etex@unexpanded{#1{#2}}}%
896 }%
897 }%
898 \x
899 \SOUL@scan
900 }
901 % \end{macrocode}
902 % \end{macro}
903 % \begin{macro}{\SOUL@addmath}
904 % \begin{macrocode}
905 \SOuL@redefine\SOUL@addmath$#1${%
906 {%
907 \let\protect\noexpand
908 \edef\x{%
909 \global\SOUL@word={%
910 \the\SOUL@word
911 {{\hbox{$#1$}}}%
912 }%
913 }%
914 \x
915 }%
916 \SOUL@scan
917 }$#1${%
918 \begingroup
919 \let\protect\noexpand
920 \edef\x{\endgroup
921 \SOUL@word={%
922 \the\SOUL@word
923 ! {\hbox{$#1$}}%
924 + {\etex@unexpanded{\hbox{$#1$}}}%
925 }%
926 }%
927 \x
928 \SOUL@scan
929 }
930 % \end{macrocode}
931 % \end{macro}
932 % \begin{macro}{\SOUL@addprotect}
933 % \begin{macrocode}
934 \SOuL@redefine\SOUL@addprotect#1#2{%
935 {%
936 \let\protect\noexpand
937 \edef\x{%
938 \global\SOUL@word={%
939 \the\SOUL@word
940 {{\hbox{#2}}}%
941 }%
942 }%
943 \x
944 }%
945 \SOUL@scan
946 }#1#2{%
947 \begingroup
948 \let\protect\noexpand
949 \edef\x{\endgroup
950 \SOUL@word={%
951 \the\SOUL@word
952 ! {\hbox{#2}}%
953 + {\etex@unexpanded{\hbox{#2}}}%
954 }%
955 }%
956 \x
957 \SOUL@scan
958 }
959 % \end{macrocode}
960 % \end{macro}
961 %
962 % \begin{macro}{\SOUL@addtoken}
963 % \begin{macrocode}
964 + \SOuL@redefine\SOUL@addtoken#1{%
965 + \edef\x{%
966 + \SOUL@word={%
967 + \the\SOUL@word
968 + \noexpand#1%
969 + }%
970 + }%
971 + \x
972 + \SOUL@scan
973 + }#1{%
974 + \edef\x{%
975 + \SOUL@word={%
976 + \the\SOUL@word
977 + \etex@unexpanded{#1}%
978 + }%
979 + }%
980 + \x
981 + \SOUL@scan
982 + }%
983 % \end{macrocode}
984 % \end{macro}
985 %
986 % \begin{macrocode}
987 \SOuL@AtEnd%
988 % \end{macrocode}
989 %
990 % \begin{macrocode}
991 %</package>
992 % \end{macrocode}
993 % \section{Installation}
994 %
995 % \subsection{Download}
996 %
997 % \paragraph{Package.} This package is available on
998 % CTAN\footnote{\CTANpkg{soul}}:
999 % \begin{description}
1000 % \item[\CTAN{macros/latex/contrib/soul/soul.dtx}] The source file.
1001 % \item[\CTAN{macros/latex/contrib/soul/soul-ori.dtx}] The source file.
1002 % \item[\CTAN{macros/latex/contrib/soul/soul.pdf}] Documentation.
1003 % \end{description}
1004 %
1005 %
1006 % \subsection{Package installation}
1007 %
1008 % Install the package with the package manager of your TeX system.
1009 % If you want to do it manually:
1010 %
1011 % \paragraph{Unpacking.}
1012 % Run tex or \LaTeX{} on the \xfile{.ins} file
1013 % \begin{quote}
1014 % \verb|tex soul.ins|
1015 % \end{quote}
1016 %
1017 % \paragraph{TDS.} Now the different files must be moved into
1018 % the different directories in your installation TDS tree
1019 % (also known as \xfile{texmf} tree):
1020 % \begin{quote}
1021 % \def\t{^^A
1022 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
1023 % soul.sty & tex/generic/soul/soul.sty\\
1024 % soul-ori.sty & tex/generic/soul/soul-ori.sty\\
1025 % soulutf8.sty & tex/latex/soul/soulutf8.sty\\
1026 % soul.pdf & doc/generic/soul/soul.pdf\\
1027 % soul-ori.pdf & doc/generic/soul/soul-ori.pdf\\
1028 % soul.dtx & source/generic/soul/soul.dtx\\
1029 % soulori.dtx & source/generic/soul/soul-ori.dtx\\
1030 % \end{tabular}^^A
1031 % }^^A
1032 % \sbox0{\t}^^A
1033 % \ifdim\wd0>\linewidth
1034 % \begingroup
1035 % \advance\linewidth by\leftmargin
1036 % \advance\linewidth by\rightmargin
1037 % \edef\x{\endgroup
1038 % \def\noexpand\lw{\the\linewidth}^^A
1039 % }\x
1040 % \def\lwbox{^^A
1041 % \leavevmode
1042 % \hbox to \linewidth{^^A
1043 % \kern-\leftmargin\relax
1044 % \hss
1045 % \usebox0
1046 % \hss
1047 % \kern-\rightmargin\relax
1048 % }^^A
1049 % }^^A
1050 % \ifdim\wd0>\lw
1051 % \sbox0{\small\t}^^A
1052 % \ifdim\wd0>\linewidth
1053 % \ifdim\wd0>\lw
1054 % \sbox0{\footnotesize\t}^^A
1055 % \ifdim\wd0>\linewidth
1056 % \ifdim\wd0>\lw
1057 % \sbox0{\scriptsize\t}^^A
1058 % \ifdim\wd0>\linewidth
1059 % \ifdim\wd0>\lw
1060 % \sbox0{\tiny\t}^^A
1061 % \ifdim\wd0>\linewidth
1062 % \lwbox
1063 % \else
1064 % \usebox0
1065 % \fi
1066 % \else
1067 % \lwbox
1068 % \fi
1069 % \else
1070 % \usebox0
1071 % \fi
1072 % \else
1073 % \lwbox
1074 % \fi
1075 % \else
1076 % \usebox0
1077 % \fi
1078 % \else
1079 % \lwbox
1080 % \fi
1081 % \else
1082 % \usebox0
1083 % \fi
1084 % \else
1085 % \lwbox
1086 % \fi
1087 % \else
1088 % \usebox0
1089 % \fi
1090 % \end{quote}
1091 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
1092 % TDS installing feature, then some files can already be in the right
1093 % place, see the documentation of \docstrip.
1094 %
1095 % \subsection{Refresh file name databases}
1096 %
1097 % If your \TeX~distribution
1098 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
1099 % these. For example, \TeX\,Live\ users run \verb|texhash| or
1100 % \verb|mktexlsr|.
1101 %
1102 %
1103 % \begin{thebibliography}{9}
1104 %
1105 % \bibitem{soul}
1106 % Melchior Franz: \textit{The \xpackage{soul} package};
1107 % 2003/11/17;\\
1108 % \CTANpkg{soul}.
1109 %
1110 % \bibitem{ucs}
1111 % Dominique P. G. Unruh: \textit{\xpackage{ucs.sty} -- Unicode Support};
1112 % 2004/10/17;\\
1113 % \CTANpkg{unicode}.
1114 %
1115 % \bibitem{utf8}
1116 % Frank Mittelbach, Chris Rowley:
1117 % \textit{Providing some UTF-8 support via \xpackage{inputenc}};
1118 % 2006/03/30;\\
1119 % \CTAN{macros/latex/base/utf8ienc.dtx}.
1120 %
1121 % \end{thebibliography}
1122 %
1123 % \begin{History}
1124 % \begin{Version}{2007/09/09 v1.0}
1125 % \item
1126 % First version.
1127 % \end{Version}
1128 % \begin{Version}{2016/05/16 v1.1}
1129 % \item
1130 % Documentation updates.
1131 % \end{Version}
1132 % \begin{Version}{2019/12/15 v1.2}
1133 % \item
1134 % Documentation updates.
1135 % \end{Version}
1136 % \begin{Version}{2023-02-18 v3.0}
1137 % \item merged soulutf8 and the original soul into one package.
1138 % \end{Version}
1139 % \begin{Version}{2023-06-14 v3.1}
1140 % \item Updated
1141 % \end{Version}
1142 % \begin{Version}{2026-03-06 v3.2}
1143 % \item Updated
1144 % \end{Version}
1145 % \end{History}
1146 %
1147 % \PrintIndex
1148 %
1149 % \Finale
1150 \endinput