summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/altsubsup/altsubsup.sty
blob: 7be8c94848deb49069c7e397fbd579009b5e4262 (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
%%
%% This is file `altsubsup.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% altsubsup.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2022 by Julien Labbé <Julien.Labbe@univ-grenoble-alpes.fr>
%% 
%% This file 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.
%% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{altsubsup}
[2022/03/15 v1.1 .dtx altsubsup file]

\ProvidesPackage{altsubsup}[2022/03/15, v1.1, Alternative and customisable
subscripts and superscripts, with  square brackets.]
\newif\ifaltsbsp@subscript    \altsbsp@subscripttrue
\newif\ifaltsbsp@superscript  \altsbsp@superscripttrue
\newif\ifaltsbsp@spbmark      \altsbsp@spbmarkfalse
\DeclareOption{subscript}   {\altsbsp@subscripttrue   \altsbsp@superscriptfalse}
\DeclareOption{superscript} {\altsbsp@subscriptfalse  \altsbsp@superscripttrue }
\DeclareOption{both}        {\altsbsp@subscripttrue   \altsbsp@superscripttrue }
\DeclareOption{spbmark}     {\altsbsp@spbmarktrue}
\DeclareOption*{\PackageWarning{altsubsup}{Unknown option \CurrentOption.}}
\ProcessOptions\relax
\ifaltsbsp@spbmark
  \RequirePackage{spbmark}
\fi
\AtBeginDocument{%
  \begingroup\catcode`\_=8 \global\let\altsbsp@standardsub=_\endgroup
  \begingroup\catcode`\^=7 \global\let\altsbsp@standardsup=^\endgroup
  \ifaltsbsp@subscript    \catcode`\_=12 \mathcode`\_="8000 \fi%
  \ifaltsbsp@superscript  \catcode`\^=12 \mathcode`\^="8000 \fi%
}
\ifaltsbsp@subscript%
\begingroup\lccode`\~=`\_\lowercase{\endgroup%
  \def~}{\@ifnextchar[% dummy bracket ]
  {\altsbsp@subwrapper}% bracket wrapper
  {\altsbsp@standardsub}% standard form
}%
\fi
\ifaltsbsp@superscript%
\begingroup\lccode`\~=`\^\lowercase{\endgroup%
  \def~}{\@ifnextchar[% dummy bracket ]
  {\altsbsp@supwrapper}% bracket wrapper
  {\altsbsp@standardsup}% standard form
}%
\fi
\def\SetAltSubscriptCommand#1{\let\altsbsp@altsubcmd#1}%
\ifaltsbsp@spbmark%
  \defspbstyle{altsub}{}
  \def\altsbsp@subwrapper[#1]{\sub[style=altsub]{\altsbsp@altsubcmd{#1}}}%
\else
  \def\altsbsp@subwrapper[#1]{\altsbsp@standardsub{\altsbsp@altsubcmd{#1}}}%
\fi
\def\SetAltSuperscriptCommand#1{\let\altsbsp@altsupcmd#1}%
\ifaltsbsp@spbmark%
  \defspbstyle{altsup}{}
  \def\altsbsp@supwrapper[#1]{\super[style=altsup]{\altsbsp@altsupcmd{#1}}}%
\else
  \def\altsbsp@supwrapper[#1]{\altsbsp@standardsup{\altsbsp@altsupcmd{#1}}}%
\fi
\newcommand{\SetAltSubSupCommands}[1]{%
  \SetAltSubscriptCommand{#1}%
  \SetAltSuperscriptCommand{#1}%
}
\RequirePackage{amstext}%
\SetAltSubSupCommands{\text}%
\ifaltsbsp@superscript%
\begingroup \catcode`\^=12%
\gdef\altsbsp@pr@m@s{% copy of \@pr@m@s code from latex.ltx
  \ifx'\@let@token
    \expandafter\pr@@@s
  \else
    \ifx^\@let@token
      \expandafter\expandafter\expandafter\pr@@@t
    \else
      \egroup
    \fi
  \fi}
\endgroup
\let\pr@m@s\altsbsp@pr@m@s
\fi
\endinput
%%
%% End of file `altsubsup.sty'.