%%
%% This is file `tabfigures.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tabfigures.dtx  (with options: `package')
%% 
%% Copyright (c) 2007 by Andreas Buehmann
%% Copyright (c) 2012 by Michael Ummels <michael.ummels@rwth-aachen.de>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Michael Ummels.
%% 
%% This work consists of the files tabfigures.dtx, tabfigures.ins and
%% the derived files tabfigures.sty and tabfigures.pdf.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabfigures}[2012/01/24 v1.1 Patches for using tabular figures]
\RequirePackage{etoolbox}
\newcommand*\tabfig@warning[1]{%
  \PackageWarningNoLine{tabfigures}{Command \string#1 could not be patched}}
\newif\iftabfig@debug\tabfig@debugfalse
\DeclareOption{debug}{\tabfig@debugtrue}
\DeclareOption{eqno}{%
  \AtBeginDocument{%
    \@ifpackageloaded{amsmath}{%
      \let\tabfig@maketag@@@\maketag@@@
      \def\maketag@@@#1{\tabfig@maketag@@@{\tabfig@ttbf{#1}}}%
    }{%
      \expandafter\def\expandafter\tabfig@eqnnum\@eqnnum
      \patchcmd{\tabfig@eqnnum}%
        {\theequation}{\tabfig@ttbf{\theequation}}%
        {\def\@eqnnum{{\tabfig@eqnnum}}}%
        {\tabfig@warning{\@eqnnum}}%
    }%
  }%
}
\DeclareOption{toc}{%
  \AtBeginDocument{%
    \let\tabfig@@dottedtocline\@dottedtocline
    \def\@dottedtocline#1#2#3#4#5{%
      \tabfig@@dottedtocline{#1}{#2}{#3}{#4}{\tabfig@ttbf{#5}}%
    }%
    \let\tabfig@numberline\numberline
    \def\numberline#1{\tabfig@numberline{\tabfig@ttbf{#1}}}%
    \let\tabfig@l@part\l@part
    \def\l@part#1#2{\tabfig@l@part{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@chapter\l@chapter
    \def\l@chapter#1#2{\tabfig@l@chapter{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@section\l@section
    \def\l@section#1#2{\tabfig@l@section{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@subsection\l@subsection
    \def\l@subsection#1#2{\tabfig@l@subsection{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@subsubsection\l@subsubsection
    \def\l@subsubsection#1#2{\tabfig@l@subsubsection{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@paragraph\l@paragraph
    \def\l@paragraph#1#2{\tabfig@l@paragraph{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@subparagraph\l@subparagraph
    \def\l@subparagraph#1#2{\tabfig@l@subparagraph{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@figure\l@figure
    \def\l@figure#1#2{\tabfig@l@figure{#1}{\tabfig@ttbf{#2}}}
    \let\tabfig@l@table\l@table
    \def\l@table#1#2{\tabfig@l@table{#1}{\tabfig@ttbf{#2}}}
    \@ifclassloaded{memoir}{%
      \apptocmd{\cftpartpresnum}%
        {\tabfig@tbf}{}{\tabfig@warning{\cftpartpresnum}}%
      \apptocmd{\cftchapterpresnum}%
        {\tabfig@tbf}{}{\tabfig@warning{\cftchapterpresnum}}%
    }{}%
  }%
}
\DeclareOption{enum}{%
  \AtBeginDocument{%
    \patchcmd{\labelenumi}%
      {\theenumi}{\tabfig@ttbf{\theenumi}}%
      {}{\tabfig@warning{\labelenumi}}%
    \patchcmd{\labelenumii}%
      {\theenumii}{\tabfig@ttbf{\theenumii}}%
      {}{\tabfig@warning{\labelenumii}}%
    \patchcmd{\labelenumiii}%
      {\theenumiii}{\tabfig@ttbf{\theenumiii}}%
      {}{\tabfig@warning{\labelenumiii}}%
    \patchcmd{\labelenumiv}%
      {\theenumiv}{\tabfig@ttbf{\theenumiv}}%
      {}{\tabfig@warning{\labelenumiv}}%
  }%
}
\DeclareOption{bib}{%
  \AtBeginDocument{%
    \let\tabfig@@biblabel\@biblabel
    \def\@biblabel#1{\tabfig@@biblabel{\tabfig@ttbf{#1}}}%
    \@ifpackageloaded{biblatex}{%
      \DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{\tabfig@ttbf{#1}}}%
      \DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{\tabfig@ttbf{#1}}}%
    }{}%
  }%
}
\DeclareOption{lineno}{%
  \AtBeginDocument{%
    \@ifpackageloaded{hypdoc}{%
      \ifpatchable{\theCodelineNo}{\HDorg@theCodelineNo}{%
        \patchcmd{\HDorg@theCodelineNo}%
          {\arabic{CodelineNo}}%
          {\tabfig@ttbf{\arabic{CodelineNo}}}%
          {}{\tabfig@warning{\HDorg@theCodelineNo}}%
      }{%
        \patchcmd{\theCodelineNo}%
          {\arabic{CodelineNo}}%
          {\tabfig@ttbf{\arabic{CodelineNo}}}%
          {}{\tabfig@warning{\theCodelineNo}}%
      }%
    }{%
      \@ifpackageloaded{doc}{%
        \patchcmd{\theCodelineNo}%
          {\arabic{CodelineNo}}%
          {\tabfig@ttbf{\arabic{CodelineNo}}}%
          {}{\tabfig@warning{\theCodelineNo}}%
      }{}%
    }%
    \@ifpackageloaded{listings}{%
      \apptocmd{\lst@numberstyle}{\tabfig@tbf}%
        {}{\tabfig@warning{\lst@numberstyle}}%
    }{}%
    \@ifpackageloaded{fancyvrb}{%
      \patchcmd{\theFancyVerbLine}%
        {\arabic{FancyVerbLine}}%
        {\tabfig@ttbf{\arabic{FancyVerbLine}}}%
        {}{\tabfig@warning{\theFancyVerbLine}}%
    }{}
  }%
}
\ProcessOptions\relax
\newcommand*\tabfig@tbf{\tbfigures}
\DeclareTextFontCommand{\tabfig@ttbf}{\tabfig@tbf}
\iftabfig@debug
  \RequirePackage{xcolor}%
  \colorlet{tabfig@debug}{green!50!black}%
  \renewcommand\tabfig@tbf{\tbfigures\color{tabfig@debug}}%
\fi
\AtBeginDocument{%
  \@ifundefined{tbfigures}{%
    \@ifpackageloaded{fontspec}{%
      \def\tbfigures{\addfontfeatures{Numbers=Monospaced}}%
    }{%
      \PackageWarningNoLine{tabfigures}{There is no command
        \string\tbfigures\space to support tabular figures}%
      \let\tabfig@tbf\@empty
    }%
  }{}%
}
%% 
%%
%% End of file `tabfigures.sty'.
