% Copyright 2007 by Nathanaël COTTIN <www.ncottin.net>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 3.

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{reference}[2009/02/13 version 1.2.0]

\RequirePackage{ifthen}

\def\@tabname{}
\def\@Tabname{}
\def\@figname{}
\def\@Figname{}
\def\@algref{}
\def\@Algref{}
\def\@appref{}
\def\@Appref{}

\provideboolean{@french}

\newcommand{\tref}[2][~]
	{\@tabname#1\ref{#2}}

\newcommand{\Tref}[2][~]
	{\@Tabname#1\ref{#2}}
	
\newcommand{\fref}[2][~]
	{\@figname#1\ref{#2}}

\newcommand{\Fref}[2][~]
	{\@Figname#1\ref{#2}}

\newcommand{\algref}[2][~]
	{\@algref#1\ref{#2}}

\newcommand{\Algref}[2][~]
	{\@Algref#1\ref{#2}}

\newcommand{\eref}[2][~]
	{\@eref#1\ref{#2}}

\newcommand{\Eref}[2][~]
	{\@Eref#1\ref{#2}}
	
\newcommand{\appref}[2][~]
	{\@appref#1\ref{#2}}

\newcommand{\Appref}[2][~]
	{\@Appref#1\ref{#2}}

\newcommand{\initrefs}
	{\if@french
		\def\@tabname{tableau}
		\def\@Tabname{Tableau}
		\def\@figname{figure}
		\def\@Figname{Figure}
		\def\@algref{algorithme}
		\def\@Algref{Algorithme}
		\def\@eref{\'equation}
		\def\@Eref{\'Equation}
		\def\@appref{annexe}
		\def\@Appref{Annexe}
	\else
		\def\@tabname{table}
		\def\@Tabname{Table}
		\def\@figname{figure}
		\def\@Figname{Figure}
		\def\@algref{algorithm}
		\def\@Algref{Algorithm}
		\def\@eref{equation}
		\def\@Eref{Equation}
		\def\@appref{appendix}
		\def\@Appref{Appendix}
	\fi}

\newcommand{\initreferences}
	{\if@french
		\def\tablename{Tableau}
		\def\figurename{Figure}
	\else
		\def\tablename{Table}
		\def\figurename{Figure}
	\fi
}

\initrefs

\AtBeginDocument{\initreferences}

\endinput