From 41d36a6ccdbe245ef49d7979b1435f03e0794e48 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 20 Jul 2014 22:12:35 +0000 Subject: fancylabel (20jul14) git-svn-id: svn://tug.org/texlive/trunk@34669 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/fancylabel/fancylabel.sty | 933 +++++++++++++++++++++ 1 file changed, 933 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/fancylabel/fancylabel.sty (limited to 'Master/texmf-dist/tex/latex/fancylabel') diff --git a/Master/texmf-dist/tex/latex/fancylabel/fancylabel.sty b/Master/texmf-dist/tex/latex/fancylabel/fancylabel.sty new file mode 100644 index 00000000000..b18ea79758a --- /dev/null +++ b/Master/texmf-dist/tex/latex/fancylabel/fancylabel.sty @@ -0,0 +1,933 @@ +%% +%% This is file `fancylabel.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% fancylabel.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2014 by Dominik Siegel +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.2 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.2 or later is part of all distributions of +%% LaTeX version 1999/12/01 or later. +%% +%% +%% To produce the documentation, do the following +%% +%% latex fancylabel.dtx +%% latex fancylabel.dtx +%% makeindex -s gind.ist -o fancylabel.ind fancylabel.idx +%% latex fancylabel.dtx +\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\ProvidesPackage{fancylabel}[2014/07/15 v1.0 Referencing in a fancy way] +\RequirePackage{xkeyval} +\RequirePackage{ifthen} +\RequirePackage{suffix} +\newcounter{fancylabel} +\setcounter{fancylabel}{0} +\newcounter{fancysublabel} +\setcounter{fancysublabel}{0} +\presetkeys{fancylabel}{numbering=continuous,% + level=sub,% + IgnoreFamilies=false,% + sort=false,% + compress=false,% + CompressLink={-},% + CompressTwo=false,% + ListLastSublabelOnly=true, + ListSeparator={,\hskip-0.16667em{ }},% + ListLastLabelSeparator=\fancyref@ListSeparator,% + ListLastRefSeparator=\fancyref@ListSeparator,% + DisableFamilyCheck=false% + }{} +\newcommand{\fancyref@addtolist}[2]{% + % #1=value to be added to the list #2 + % #2=list + \ifthenelse{\equal{#1}{}}{}{% + \ifthenelse{\equal{#2}{}}{}{% + \g@addto@macro{#2}{,}% + }% + \g@addto@macro{#2}{#1}% + }% +} +\newcommand{\fancyref@addtoprintlist}[2]{% + % #1=value to be added to the list #2 + % #2=list + \ifthenelse{\equal{#1}{}}{}{% + \ifthenelse{\equal{#2}{}}{}{% + \g@addto@macro{#2}{\fancyref@ListSeparator}% + }% + \g@addto@macro{#2}{#1}% + }% +} +\define@key{fancylabel}{families}{% + \fancyref@foreach{\fancyref@DefineFamily}{}{#1}% +} +\newcommand{\fancyref@ListOfFamilies}{} +\newcommand{\fancyref@DefineFamily}[2]{% + % #1=empty + % #2=family + \@namedef{fancylabel@familystorage@#2}{0}% + \@namedef{fancylabelformat#2}{#2-\arabic{fancylabel}}% + \@namedef{fancyonlysublabelformat#2}{\alph{fancysublabel}}% + \@namedef{fancysublabelformat#2}{#2-\arabic{fancylabel}\alph{fancysublabel}}% + \@namedef{fancylabel@list@#2}{}% + \fancyref@addtolist{#2}{\fancyref@ListOfFamilies}% +} +\@onlypreamble\fancyref@DefineFamily +\fancyref@DefineFamily{}{default} +\renewcommand{\fancylabelformatdefault}{\arabic{fancylabel}} +\renewcommand{\fancysublabelformatdefault}{\arabic{fancylabel}\alph{fancysublabel}} +\define@choicekey*+{fancylabel}{numbering}[\val\nr]{continuous,ondemand,referenced}{% + % ##1=family + % ##2=label + % ##3=sublabel + \ifcase\nr\relax% + % numbering=continuous + % Label will be set un the first time, \fancylabel{} is called + % Order of labels depends on the appearance of fancylabel{} + \newcommand{\fancyref@define@LabelUndef}[3]{% + \fancyref@newlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@show@LabelUndef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@define@LabelDef}[3]{}% + \newcommand{\fancyref@show@LabelDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@define@RefUndef}[3]{}% + \newcommand{\fancyref@show@RefUndef}[3]{% + \@ifundefined{fancyref@PrevRun@##1@##2@##3}{% + \fancyref@labelerror{##2}{##3}% + ???% + }{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@define@RefDef}[3]{}% + \newcommand{\fancyref@show@RefDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \or% + % numbering=ondemand + % Only set label if it was asked for during the last run + % Order of labels depends on the appearance of fancylabel{} + \newcommand{\fancyref@define@LabelUndef}[3]{% + \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{% + \fancyref@newlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@show@LabelUndef}[3]{% + \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@define@LabelDef}[3]{}% + \newcommand{\fancyref@show@LabelDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@define@RefUndef}[3]{}% + \newcommand{\fancyref@show@RefUndef}[3]{% + \@ifundefined{fancyref@PrevRun@##1@##2@##3}{% + \fancyref@labelerror{##2}{##3}% + ???% + }{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@define@RefDef}[3]{}% + \newcommand{\fancyref@show@RefDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \or% + % numbering=referenced + % Only set label if it was asked for during the last run + % Order of labels depends on the appearance of fancyref{} + \newcommand{\fancyref@define@LabelUndef}[3]{}% + \newcommand{\fancyref@show@LabelUndef}[3]{% + \@ifundefined{fancyref@AskedPrevRun@##1@##2@##3}{}{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@define@LabelDef}[3]{}% + \newcommand{\fancyref@show@LabelDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@define@RefUndef}[3]{% + \fancyref@newlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@show@RefUndef}[3]{% + \@ifundefined{fancyref@PrevRun@##1@##2@##3}{% + \fancyref@labelerror{##2}{##3}% + ???% + }{% + \fancyref@showlabel{##1}{##2}{##3}% + }% + }% + \newcommand{\fancyref@define@RefDef}[3]{% + \fancyref@newlabel{##1}{##2}{##3}% + }% + \newcommand{\fancyref@show@RefDef}[3]{% + \fancyref@showlabel{##1}{##2}{##3}% Show label + }% + \fi% +}{% + \PackageError{fancylabel}{This value is not allowed. Allowed values are:% + 'continuous'(default), 'ondemand', 'referenced'.}{}% +} +\define@choicekey*+{fancylabel}{level}[\val\nr]{sub,same}{% + % ##1=family + % ##2=label + % ##3=sublabel + \ifcase\nr\relax% + % level=sub + \DeclareRobustCommand\fancysublabel[3][default]{{% + \fancysubreftrue% + \fancyref@subrefminusfalse% + \@fancylabel{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysublabel-[3][default]{{% + \fancysubreftrue% + \fancyref@subrefminustrue% + \@fancylabel{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysublabel*[3][default]{{% + \renewcommand{\@@fancylabel@show}[2]{}% + \fancysubreftrue% + \fancyref@subrefminusfalse% + \@fancylabel{##1}{##2}{##3}% + }}% + \DeclareRobustCommand\fancysubref[3][default]{{% + \fancysubreftrue% + \fancyref@subrefminusfalse% + \@fancyref{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysubref-[3][default]{{% + \fancysubreftrue% + \fancyref@subrefminustrue% + \@fancyref{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysubref*[3][default]{{% + \renewcommand{\@@fancylabel@show}[2]{}% + \fancysubreftrue% + \fancyref@subrefminusfalse% + \@fancyref{##1}{##2}{##3}% + }}% + \or% + % level=same + \DeclareRobustCommand\fancysublabel[3][default]{{% + \fancysubreffalse% + \fancyref@subrefminusfalse% + \@fancylabel{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysublabel-[3][default]{{% + \fancysubreffalse% + \fancyref@subrefminustrue% + \@fancylabel{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysublabel*[3][default]{{% + \renewcommand{\@@fancylabel@show}[2]{}% + \fancysubreffalse% + \fancyref@subrefminusfalse% + \@fancylabel{##1}{##2}{##3}% + }}% + \DeclareRobustCommand\fancysubref[3][default]{{% + \fancysubreffalse% + \fancyref@subrefminusfalse% + \@fancyref{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysubref-[3][default]{{% + \fancysubreffalse% + \fancyref@subrefminustrue% + \@fancyref{##1}{##2}{##3}% + }}% + \WithSuffix\DeclareRobustCommand\fancysubref*[3][default]{{% + \renewcommand{\@@fancylabel@show}[2]{}% + \fancysubreffalse% + \fancyref@subrefminusfalse% + \@fancyref{##1}{##2}{##3}% + }}% + \fi% +}{% + \PackageError{fancylabel}{This value is not allowed. Allowed values are:% + 'sub'(default), 'same'.}{}% +} +\newif\iffancyref@subrefminus\fancyref@subrefminusfalse +\define@boolkey{fancylabel}{IgnoreFamilies}{} +\define@boolkey{fancylabel}{sort}{} +\define@boolkey{fancylabel}{compress}{} +\define@key{fancylabel}{CompressLink}{\def\fancyref@CompressLink{#1}} +\define@boolkey{fancylabel}{CompressTwo}{} +\define@boolkey{fancylabel}{ListLastSublabelOnly}{} +\define@key{fancylabel}{ListSeparator}{\edef\fancyref@ListSeparator{#1}} +\define@key{fancylabel}{ListLastLabelSeparator}{\edef\fancyref@ListLastLabelSeparator{#1}} +\define@key{fancylabel}{ListLastRefSeparator}{\edef\fancyref@ListLastRefSeparator{#1}} +\define@boolkey{fancylabel}{DisableFamilyCheck}{} +\newif\iffancyref@rerunerror\fancyref@rerunerrorfalse % ReRun error +\newif\iffancysubref\fancysubreffalse % Subref or Ref +\AtEndDocument{% + \iffancyref@rerunerror% + \PackageWarning{fancylabel}{Fancylabels may have changed. % + Please run latex again.}% + \fi% +} +\newcommand{\fancyref@labelerror}[2]{% + % #1=label + % #2=sublabel + \ifthenelse{\equal{#2}{}}{% + \PackageWarning{fancylabel}{Undefined fancylabel "#1".}% + }{% + \PackageWarning{fancylabel}{Undefined fancysublabel "#1@#2".}% + }% + \global\fancyref@rerunerrortrue% +} +\DeclareRobustCommand\fancylabel[2][default]{{% + % #1=family + % #2=label or list of labels + \fancysubreffalse% + \@fancylabel{#1}{#2}{}% +}} +\WithSuffix\DeclareRobustCommand\fancylabel*[2][default]{{% + % #1=family + % #2=label or list of labels + \renewcommand{\@@fancylabel@show}[2]{}% + \fancysubreffalse% + \@fancylabel{#1}{#2}{}% +}} +\DeclareRobustCommand\fancyref[2][default]{{% + % #1=family + % #2=label or list of labels + \@fancyref{#1}{#2}{}% +}} +\WithSuffix\DeclareRobustCommand\fancyref*[2][default]{{% + % #1=family + % #2=label or list of labels + \renewcommand{\@@fancylabel@show}[2]{}% + \@fancyref{#1}{#2}{}% +}} +\newcommand{\fancylabelNewLabelEvent}{} +\newcommand{\fancylabelShowLabelEvent}{} +\newcommand{\fancylabelShowRefEvent}{} +\newcommand{\fancylabelResetCounter}[1]{% + % #1=family + \@ifundefined{fancylabel@familystorage@#1}{% + \PackageError{fancylabel}{No fancylabel family '#1' defined.}{}% + }{% + \@namedef{fancylabel@familystorage@#1}{0}% + }% +} +\newif\iffancyref@showlabel@FirstSublabelInList% +\fancyref@showlabel@FirstSublabelInListtrue% +\newcommand{\@fancylabel}[3]{% + % #1=family + % #2=label or list of labels + % #3=sublabel or list of sublabels + \@fancylabelANDref{#1}{#2}{#3}% + % Define labels + \expandafter\fancyref@@sort\expandafter{\@fancylabel@list}{\@@fancylabel@define}% + % Print labels + \setcounter{fancyref@sort@x}{0}% + \expandafter\fancyref@@sort\expandafter{\fancyref@compress@list}{\@@fancylabel@show}% + \fancyref@print@list% +} +\newcommand{\@fancylabelANDref}[3]{% + % #1=family + % #2=label or list of labels + % #3=sublabel or list of sublabels + \def\fancyref@sort@list{}% + \def\fancyref@sort@labellist@unsorted{}% + \def\fancyref@compress@list{}% + \def\fancyref@print@list{}% + \ifthenelse{\equal{#3}{}}{% + % true => List of labels + \newcommand{\@fancylabel@list}{#2}% + \newcommand{\@@fancylabel@define}[2]{% + % ##1= + % ##2=label (from list) + \@@@fancylabel@define{#1}{##2}{#3}% + }% + \newcommand{\@@fancyref@define}[2]{% + % ##1= + % ##2=label (from list) + \@@@fancyref@define{#1}{##2}{#3}% + }% + \def\fancyref@@@@@sort{% + fancyref@PrevRun@#1@\fancyref@@sort@value @% + }% + \def\fancyref@@@compress{% + fancyref@PrevRun@#1@\fancyref@@compress@value @% + }% + \newcommand{\fancyref@@@compress@entry}{% + {#1}{\fancyref@@compress@value}{}% + }% + }{% + % false => List of sublabels + \newcommand{\@fancylabel@list}{#3}% + \newcommand{\@@fancylabel@define}[2]{% + % ##1= + % ##2=sublabel (from list) + \@@@fancylabel@define{#1}{#2}{##2}% + }% + \newcommand{\@@fancyref@define}[2]{% + % ##1= + % ##2=sublabel (from list) + \@@@fancyref@define{#1}{#2}{##2}% + }% + \def\fancyref@@@@@sort{% + fancyref@PrevRun@#1@#2@\fancyref@@sort@value% + }% + \def\fancyref@@@compress{% + fancyref@PrevRun@#1@#2@\fancyref@@compress@value% + }% + \newcommand{\fancyref@@@compress@entry}{% + {#1}{#2}{\fancyref@@compress@value}% + }% + }% + % Sort + \fancyref@sort{\@fancylabel@list}% + % Compress + \fancyref@compress{\fancyref@sort@list}% + % Add the so far undefined labels to this list + \ifthenelse{\equal{\fancyref@sort@labellist@unsorted}{}}{}{% + \KV@fancylabel@compressfalse% + \fancyref@compress{\fancyref@sort@labellist@unsorted}% + \expandafter\fancyref@addtolist\expandafter{\fancyref@sort@labellist@unsorted}% + {\fancyref@sort@list}% + }% +} +\newcommand{\@@@fancylabel@define}[3]{% + % #1=family + % #2=label + % #3=sublabel + \@ifundefined{fancylabel@familystorage@#1}{% + \PackageError{fancylabel}{No fancylabel family '#1' defined. % + Use package option families for definition.}{}% + }{% + \@ifundefined{fancyref@ThisRun@#1@#2@#3}{% + \fancyref@define@LabelUndef{#1}{#2}{#3}% + }{% + \fancyref@define@LabelDef{#1}{#2}{#3}% + }% + }% +} +\newcommand{\@@fancylabel@show}[2]{% + % #1= + % #2={}{