We want `Eqn. (a)` and `Fig. b`, not `Fig. (b)`.
\makeatother
% An reference index from an unspecified source
-% usage: \iref{value}
-% for example: \iref{75}
-\newcommand{\iref}[1]{(#1)}
+% usage: \iref{environment}{value}
+% for example: \iref{equation}{75}
+\newcommand{\iref}[2]{%
+ \switch%
+ \case{\isequal{#1}{equation}}%
+ ({#2})%
+ \otherwise%
+ {#2}%
+ \endswitch%
+}
% A formatted reference from an unspecified source
% usage: \fref{environment}{value}
\newcommand{\fref}[2]{%
\switch%
\case{\isequal{#1}{equation}}%
- Eqn.~\iref{#2}%
+ Eqn.~\iref{#1}{#2}%
\case{\isequal{#1}{figure}}%
- Fig.~\iref{#2}%
+ Fig.~\iref{#1}{#2}%
\otherwise%
\PackageError{fref}{
\MessageBreak