diff options
author | Karl Berry <karl@freefriends.org> | 2013-07-11 23:26:05 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-07-11 23:26:05 +0000 |
commit | 1407e4e5ea60e9d4e79a57bca0c2f248f6e9de9a (patch) | |
tree | beb13dc96321878b8635c0c02539fa663807fc70 /Master/texmf-dist/tex/latex/stackengine | |
parent | 2da7d143a3c5fa97ad562e2acfc3e487d53598d1 (diff) |
stackengine (11jul13)
git-svn-id: svn://tug.org/texlive/trunk@31168 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/stackengine')
-rw-r--r-- | Master/texmf-dist/tex/latex/stackengine/stackengine.sty | 168 |
1 files changed, 89 insertions, 79 deletions
diff --git a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty index 3c7176ec07b..d58573f55e2 100644 --- a/Master/texmf-dist/tex/latex/stackengine/stackengine.sty +++ b/Master/texmf-dist/tex/latex/stackengine/stackengine.sty @@ -1,5 +1,6 @@ +\def\stackengineversionnumber{v2.0} \ProvidesPackage{stackengine} -[2013/06/12 v1.0 +[2013/07/11 \stackengineversionnumber Stacking text and objects in convenient ways] % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -13,14 +14,20 @@ % % The Current Maintainer of this work is Steven B. Segletes. % -% V1.0 Initial release. +% V1.0 -Initial release. +% V2.0 -Revised syntax, making \Sstackgap=len, \Lstackgap=len syntax +% obsolete. New syntax is \setstackgap{S}{len} and +% \setstackgap{L}{len} +% -Condensed several routines +% -Revised documentation for clarity and to eliminate typos. +% -Added \toplap and \bottomlap. +% -Disallowed \quietstack for lapping. +% -added \abovebaseline \usepackage{calc} \usepackage{readarray} \newcounter{stackindex} -\newlength\Sstackgap -\newlength\Lstackgap \newlength\boxshift \newlength\stack@tmplength \global\newlength\stackedboxwidth @@ -28,10 +35,42 @@ \newsavebox\anchorbox \newsavebox\stackedbox -\newcommand\stackgap{\if S\stacktype\the\Sstackgap\else\the\Lstackgap\fi} +%% Following 3 lines thanks to Prof. Enrico Gregorio, from: +%% http://tex.stackexchange.com/questions/42318/ +%% removing-a-backslash-from-a-character-sequence +\begingroup\lccode`\|=`\\ +\lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}} +\newcommand{\stack@macro@name}[1]{\expandafter\removebs\string#1} -\global\Sstackgap=3pt % SHORTSTACKING GAP BETWEEN ITEMS (SAME AS \shortstack) -\global\Lstackgap=\baselineskip % LONGSTACKING GAP BETWEEN ITEMS (def. \baselineskip) +\newif\ifstackengine@oldsyntax +\DeclareOption{oldsyntax}{\stackengine@oldsyntaxtrue} +\ProcessOptions\relax +\ifstackengine@oldsyntax% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%% THIS VERSION 1.0 SYNTAX WAS PHASED OUT %%%%%%%%%%%%%%%%%%% +%%%%% (but can invoke with \usepackage[oldsyntax]{stackengine} ) +\newlength\Sstackgap +\newlength\Lstackgap +\newcommand\stackgap{\if S\stacktype\the\Sstackgap\else\the\Lstackgap\fi} +\global\setlength{\Sstackgap}{3pt} +\global\setlength{\Lstackgap}{\baselineskip} +\else% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%% AND REPLACED WITH THE FOLLOWING %%%%%%%%%%%%%%%%%%%%%%%%%% +% Again, thanks to Prof. Gregorio for his lucid explanation that helped +% improve this package. See: +% http://tex.stackexchange.com/questions/123443/ +% defining-a-length-that-scales-with-fontsize-changes/123470#123470 +\newcommand{\setstackgap}[2]{% + \@namedef{#1stackgap}{#2}% +} +\newcommand\stackgap{% + \@nameuse{\if S\stacktype S\else L\fi stackgap}\relax +} +\setstackgap{S}{3pt}% SHORTSTACKING GAP BETWEEN ITEMS (SAME AS \shortstack) +\setstackgap{L}{\baselineskip}% LONGSTACKING GAP BETWEEN ITEMS (def. \baselineskip) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\fi \def\useanchorwidth{F}% T= FORCE BOX WIDTH TO ANCHOR-WIDTH \def\quietstack{F}% T = SUPPRESS OUTPUT OF ALL COMMANDS % (USE \usebox{\stackedbox} TO RETRIEVE) @@ -100,84 +139,59 @@ \if F#6\usebox{\stackedbox}\fi% } -\newcommand*\stackunder[3][\stackgap]{% - \stackengine{#1}{#2}{#3}{U}{\stackalignment}{\quietstack}{\useanchorwidth}% - {\stacktype}} +\newcommand*\stackunder[3][\stackgap]{\stackengine% + {#1}{#2}{#3}{U}{\stackalignment}{\quietstack}{\useanchorwidth}{\stacktype}} -\newcommand*\stackon[3][\stackgap]{% - \stackengine{#1}{#2}{#3}{O}{\stackalignment}{\quietstack}{\useanchorwidth}% - {\stacktype}} +\newcommand*\stackon[3][\stackgap]{\stackengine% + {#1}{#2}{#3}{O}{\stackalignment}{\quietstack}{\useanchorwidth}{\stacktype}} -\newcommand*\Shortstack[2][\stackalignment]{% - \getargsC{#2}% - \setcounter{stackindex}{1}% - \sbox{\stackedbox}{\argi}% - \whiledo{\thestackindex < \narg}{% - \stepcounter{stackindex}% - \stackengine{\Sstackgap}{\csname arg\roman{stackindex}\endcsname}% - {\usebox{\stackedbox}}{O}{#1}{T}{\useanchorwidth}{S}% - }% - \if F\quietstack\usebox{\stackedbox}\fi% -} +\newcommand*\Shortstack[2][\stackalignment]{\@stack{#1}{#2}{O}{S}} -\newcommand*\Shortunderstack[2][\stackalignment]{% - \getargsC{#2}% - \setcounter{stackindex}{\narg}% - \sbox{\stackedbox}{\csname arg\roman{stackindex}\endcsname}% - \whiledo{\thestackindex > 1}{% - \addtocounter{stackindex}{-1}% - \stackengine{\Sstackgap}{\csname arg\roman{stackindex}\endcsname}% - {\usebox{\stackedbox}}{U}{#1}{T}{\useanchorwidth}{S}% - }% - \if F\quietstack\usebox{\stackedbox}\fi% -} +\newcommand*\Longstack[2][\stackalignment]{\@stack{#1}{#2}{O}{L}} -\newcommand*\Longstack[2][\stackalignment]{% - \getargsC{#2}% - \setcounter{stackindex}{1}% - \sbox{\stackedbox}{\argi}% - \whiledo{\thestackindex < \narg}{% - \stepcounter{stackindex}% - \stackengine{\Lstackgap}{\csname arg\roman{stackindex}\endcsname}% - {\usebox{\stackedbox}}{O}{#1}{T}{\useanchorwidth}{L}% - }% - \if F\quietstack\usebox{\stackedbox}\fi% -} +\newcommand*\Shortunderstack[2][\stackalignment]{\@stack{#1}{#2}{U}{S}} + +\newcommand*\Longunderstack[2][\stackalignment]{\@stack{#1}{#2}{U}{L}} -\newcommand*\Longunderstack[2][\stackalignment]{% +\newcommand*\@stack[4]{% \getargsC{#2}% - \setcounter{stackindex}{\narg}% + \if U#3% + \setcounter{stackindex}{\narg}% + \def\@stacksign{-}% + \def\@stackcondition{\thestackindex > 1}% + \else% + \setcounter{stackindex}{1}% + \def\@stacksign{}% + \def\@stackcondition{\thestackindex < \narg}% + \fi% \sbox{\stackedbox}{\csname arg\roman{stackindex}\endcsname}% - \whiledo{\thestackindex > 1}{% - \addtocounter{stackindex}{-1}% - \stackengine{\Lstackgap}{\csname arg\roman{stackindex}\endcsname}% - {\usebox{\stackedbox}}{U}{#1}{T}{\useanchorwidth}{L}% + \whiledo{\@stackcondition}{% + \addtocounter{stackindex}{\@stacksign 1}% + \stackengine{\csname#4stackgap\endcsname}% + {\csname arg\roman{stackindex}\endcsname}% + {\usebox{\stackedbox}}{#3}{#1}{T}{\useanchorwidth}{#4}% }% \if F\quietstack\usebox{\stackedbox}\fi% } -\newcommand*\tllap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{O}{r}{\quietstack}{T}{L}% -} +% PERHAPS THESE SIX MACROS CAN BE REPLACED BY \toplap AND \bottomlap +\newcommand*\tllap[2][\Lstackgap]{\@stacklap{#1}{l}{#2}{O}} +\newcommand*\tclap[2][\Lstackgap]{\@stacklap{#1}{c}{#2}{O}} +\newcommand*\trlap[2][\Lstackgap]{\@stacklap{#1}{r}{#2}{O}} +\newcommand*\bllap[2][\Lstackgap]{\@stacklap{#1}{l}{#2}{U}} +\newcommand*\bclap[2][\Lstackgap]{\@stacklap{#1}{c}{#2}{U}} +\newcommand*\brlap[2][\Lstackgap]{\@stacklap{#1}{r}{#2}{U}} -\newcommand*\tclap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{O}{c}{\quietstack}{T}{L}% -} +\newcommand*\toplap[3][\Lstackgap]{\@stacklap{#1}{#2}{#3}{O}} -\newcommand*\trlap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{O}{l}{\quietstack}{T}{L}% -} - -\newcommand*\bllap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{U}{r}{\quietstack}{T}{L}% -} +\newcommand*\bottomlap[3][\Lstackgap]{\@stacklap{#1}{#2}{#3}{U}} -\newcommand*\bclap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{U}{c}{\quietstack}{T}{L}% -} - -\newcommand*\brlap[2][\Lstackgap]{% - \stackengine{#1}{}{#2}{U}{l}{\quietstack}{T}{L}% +\newcommand*\@stacklap[4]{% + \if l#2\stackengine{#1}{}{#3}{#4}{r}{F}{T}{L}\else% + \if r#2\stackengine{#1}{}{#3}{#4}{l}{F}{T}{L}\else% + \stackengine{#1}{}{#3}{#4}{c}{F}{T}{L}% + \fi% + \fi } \newcommand*\stackanchor[3][\stackgap]{% @@ -196,6 +210,10 @@ {\stackalignment}{\quietstack}{F}{\stacktype}% } +\newcommand*\abovebaseline[2][\stackgap]{% + \stackengine{#1}{}{#2}{O}{\stackalignment}{\quietstack}{F}% + {\stacktype}} + \newcommand*\belowbaseline[2][\stackgap]{% \stackengine{#1}{}{#2}{U}{\stackalignment}{\quietstack}{F}% {\stacktype}} @@ -224,12 +242,4 @@ \protected@edef#1{\usebox{\csname\sv@name content\endcsname}}% } -% Following 3 lines thanks to Prof. Enrico Gregorio, from: -% http://tex.stackexchange.com/questions/42318/ -% removing-a-backslash-from-a-character-sequence -\begingroup\lccode`\|=`\\ -\lowercase{\endgroup\def\removebs#1{\if#1|\else#1\fi}} -\newcommand{\stack@macro@name}[1]{\expandafter\removebs\string#1} -% - \endinput |