% Upper-case    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
% Lower-case    a b c d e f g h i j k l m n o p q r s t u v w x y z
% Digits        0 1 2 3 4 5 6 7 8 9
% Exclamation   !           Double quote "          Hash (number) #
% Dollar        $           Percent      %          Ampersand     &
% Acute accent  '           Left paren   (          Right paren   )
% Asterisk      *           Plus         +          Comma         ,
% Minus         -           Point        .          Solidus       /
% Colon         :           Semicolon    ;          Less than     <
% Equals        =           Greater than >          Question mark ?
% At            @           Left bracket [          Backslash     \
% Right bracket ]           Circumflex   ^          Underscore    _
% Grave accent  `           Left brace   {          Vertical bar  |
% Right brace   }           Tilde        ~

% ---------------------------------------------------------------------|
% --------------------------- 72 characters ---------------------------|
% ---------------------------------------------------------------------|

% ======================================================================
% SPECIAL HANDLING OF CROSS-REFERENCES
% ======================================================================
%
% (c) Copyright 2007 by Theodore P. Pavlic
%
%
% THE FOLLOWING implement \shortref, \longref, and \longrefs mentioned
% below. 
%
% An existing package exists on CTAN called refstyle that could be used
% to replace the following. However, this package only makes links from
% the reference numbers. For example, instead of linking "Fig. 1", it
% links just the "1".
%

% The names of sections, equations, etc.
\newcommand{\chname}{Chapter}
\newcommand{\secname}{Section}
\newcommand{\appname}{Appendix}
\newcommand{\appplural}{Appendices}
\newcommand{\figname}{Figure}
\newcommand{\tabname}{Table}
\newcommand{\eqname}{Equation}

% Reference management (with color)
%
% (if using biblatex, be sure to disable backref)
\usepackage{prettyref}
\usepackage[%dvipdfm,   % For producing DVI's
            pdfpagelabels,hypertexnames=true,pagebackref,
            %pdfpagelabels,hypertexnames=false,pagebackref,
            plainpages=false,naturalnames=false]{hyperref}
\usepackage{color}
\definecolor{darkblue}{rgb}{0,0.1,0.5}
\hypersetup{colorlinks,
            linkcolor=darkblue,anchorcolor=darkblue,citecolor=darkblue}
% \bracketref is defined in the index management file
%\ifthenelse{\isundefined{\backref}}
%           {}{\renewcommand*{\backref}[1]{\nohyperbracketref{#1}}}
\ifthenelse{\isundefined{\backref}}
           {}{\renewcommand*{\backref}[1]{\bracketref{#1}}}

% These reference formats work with \prettyref to associate a label name
% prefix (e.g. "fig:") with a reference format. \hyperref is used within
% each format in order to link the entire reference to its target.
%
% \autoref could be used instead of \prettyref. In that case, the \*name
% and/or \*autorefname macros would need to be redefined in a similar
% fashion and all \prettyref would have to be changed to \autoref.
% However, if this was done, it may be difficult to automatically place
% parentheses around equation numbers.
%
% NOTE: \autoref seems to have trouble with the Figure counter being
%       tied to sections, so it is best without it anyway. Use
%       hypertexnames=false as a hyperref option.
\newboolean{prettyrefname}    \setboolean{prettyrefname}{false}
\newboolean{prettyrefplural}  \setboolean{prettyrefplural}{false}
\newcommand{\prettyrefends}{\ifthenelse{\boolean{prettyrefplural}}{s}{}}
\newrefformat{item}
     {\hyperref[#1]{\textup{\ref*{#1}}}}
\newrefformat{ch}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\chname{}\prettyrefends{}~}
                               {}%
                    \textup{\ref*{#1}}}}
\newrefformat{sec}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\secname{}\prettyrefends{}~}
                               {}%
                    \textup{\ref*{#1}}}}
\newrefformat{app}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\ifthenelse{\boolean{prettyrefplural}}
                                           {\appplural}{\appname{}}~}
                               {}%
                    \textup{\ref*{#1}}}}
\newrefformat{fig}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\figname{}\prettyrefends{}~}
                               {}%
                    \textup{\ref*{#1}}}}
\newrefformat{tab}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\tabname{}\prettyrefends{}~}
                               {}%
                    \textup{\ref*{#1}}}}
\newrefformat{eq}
     {\hyperref[#1]{\ifthenelse{\boolean{prettyrefname}}
                               {\eqname{}\prettyrefends{}~}
                               {}%
                    \textup{(\ref*{#1})}}}

% The following implements a generalized hyperlinked \eqref
%
% \longref and \longrefs cause \prettyref to make a hyperlinked
% reference with a name (e.g. "Fig. 1" and "Figs. 1" respectively)
%
% \shortref makes a hypyerlinked reference with no name (e.g. "(1)"
% for an equation and "1" for a figure
\newcommand{\shortref}[1]{\setboolean{prettyrefname}{false}%
                          \prettyref{#1}}
                          
\newcommand{\longref}[1]{\setboolean{prettyrefname}{true}%
                         \setboolean{prettyrefplural}{false}%
                         \prettyref{#1}}

\newcommand{\longrefs}[1]{\setboolean{prettyrefname}{true}%
                          \setboolean{prettyrefplural}{true}%
                          \prettyref{#1}}

% This concludes the referencing code
% ======================================================================
