Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % -*- LaTeX -*-
- \ProvidesPackage{subperscript}
- %%%%%%%%%%% AUTOMATH
- % this allows _ to be used in horizontal mode (from J.Frampton):
- % Reimplemented to allow this feature to be turned on and off.
- % The new version also combines sub- and superscripts properly.
- % -Alexis
- % Sub- and superscripting functionality from gb4e, packaged by Antonio Fortin
- % \automath Make _ and ^ work outside math mode
- % \noautomath Restore normal sub/superscript behavior
- { % Temporarily change catcodes
- \catcode`\_=\active
- \catcode`\^=\active
- \global\def\automath{%
- \catcode`\_=\active
- \catcode`\^=\active
- \def_##1{\gb@ifnextchar^{\automath@two_{##1}}{\ensuremath{\sb{##1}}}}%
- \def^##1{\gb@ifnextchar_{\automath@two^{##1}}{\ensuremath{\sp{##1}}}}}
- }
- \def\automath@two#1#2#3#4{\ensuremath{#1{#2}\relax #3{#4}}}
- % Restore default catcodes for ^, _
- \def\noautomath{\catcode`\_=8 \catcode`\^=7 }
- % The original \@ifnextchar discards spaces when looking for the next
- % ``character''. This variant accepts any token.
- \long\def\gb@ifnextchar#1#2#3{%
- \let\reserved@d=#1%
- \def\reserved@a{#2}%
- \def\reserved@b{#3}%
- \futurelet\@let@token\@gbifnch}
- \def\@gbifnch{%
- \ifx\@let@token\reserved@d
- \let\reserved@c\reserved@a
- \else
- \let\reserved@c\reserved@b
- \fi
- \reserved@c}
- \noautomath % On by default, for backward compatibility
- %%%%%%%%%
- \def\lb#1{\@ifnextchar [{\@glarph{#1}}{\@bl{#1}}}
- \def\@glarph#1[#2]{\ifmmode{[}\sb{{\mathrm{#1}}\sb{#2}}\else%
- ${[}\sb{{\mathrm{#1}}\sb{#2}}$\fi}
- \def\@bl#1{\ifmmode{[}\sb{\mathrm{#1}}\;\else${[}\sb{\mathrm{#1}}\;$\fi}
- \def\rb#1{\@ifnextchar [{\@grarph{#1}}{\@br{#1}}}
- \def\@grarph#1[#2]{\ifmmode{]}\sb{{\mathrm{#1}}\sb{#2}}\else%
- ${]}\sb{{\mathrm{#1}}\sb{#2}}$\fi}
- \def\@br#1{\ifmmode{]}\sb{\mathrm{#1}}\;\else${]}\sb{\mathrm{#1}}\;$\fi}
- %%% END_NEWSTUFF.
Advertisement
Comments
-
Allows
_
to be used in horizontal mode (from J. Frampton):
Reimplemented to allow this feature to be turned on and off.
The new version also combines sub- and superscripts properly.- Alexis Dimitriadis
Sub- and superscripting functionality from gb4e, packaged by Antonio Fortin
Add Comment
Please, Sign In to add comment
Advertisement