[Tex/LaTex] Left/Center/Right references to subfigures

captionshorizontal alignment

I have a figure with three subfigures shown in the code sample below. How can I change the reference to a subfigure so that I have Figure 1 (left), Figure 1 (center), and Figure 1 (right) instead of figure 1.1, 1.2, and 1.3? Also, in the caption I would like to it to have a general caption, then in the same paragraph have (left) left's caption (center) center's caption (right) right's caption.

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure*}
\begin{minipage}[b]{0.33\linewidth}
\label{fig:left}
\includegraphics[width=2.5in,height=2.5in]{img1}
\end{minipage}
\begin{minipage}[b]{0.33\linewidth}
\includegraphics[width=2.5in,height=2.5in]{img2}
\label{fig:center}
\end{minipage}
\begin{minipage}[b]{0.33\linewidth}
\includegraphics[width=2.5in,height=2.5in]{img3}
\label{fig:right}
\end{minipage}
\caption{
    Blah blah blah.  
    \ref{fig:left} blah blah.   
    \ref{fig:center} blah blah.   
    \ref{fig:right} blah blah.
}
\label{fig:all}
\end{figure*}
\end{document}

Best Answer

In what follows, a new numbering system called \lcr is defined (which works the same way as \arabic, \alph, etc. do) that associates "left" to "1", "centre" to "2", and "right" to "3".

The prettyref package is then used to customise the cross-referencing to either of the three "subfigures". Note that \phantomsubcaption must be used in order to create an anchor for \ref.

\documentclass{article}

\makeatletter
\def\lcr#1{\expandafter\@lcr\csname c@#1\endcsname}% LaTeX
\def\@lcr#1{%
  \ifnum#1=0%
    \@ctrerr% 
  \else\ifnum#1=1%
      left%
    \else\ifnum#1=2%
       center%
     \else\ifnum#1=3%
        right%
      \else
        \@ctrerr%
      \fi
    \fi
  \fi
}
\makeatother

\usepackage{subcaption}

\DeclareCaptionSubType*{figure}
\renewcommand\thesubfigure{\thefigure~(\lcr{subfigure})}

\usepackage{prettyref}
\newrefformat{subfiglcr}{Figure~\ref{#1}}

\usepackage{tikz}
%\usepackage{graphicx}

\begin{document}

\begin{figure*}
    \begin{minipage}[b]{0.3\linewidth}
        \centering
        \begin{tikzpicture}
            \path[draw=red,fill=red!20] (0,0) rectangle (4,4);
        \end{tikzpicture}
        \phantomsubcaption \label{subfiglcr:left}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.3\linewidth}
        \centering
        \begin{tikzpicture}
            \path[draw=green,fill=green!20] (0,0) rectangle (4,4);
        \end{tikzpicture}
        \phantomsubcaption \label{subfiglcr:center}
    \end{minipage}
    \hfill
    \begin{minipage}[b]{0.3\linewidth}
        \centering
        \begin{tikzpicture}
            \path[draw=blue,fill=blue!20] (0,0) rectangle (4,4);
        \end{tikzpicture}
        \phantomsubcaption \label{subfiglcr:right}
    \end{minipage}
    \caption{Three squares. Left: red. Center: green. Right: blue.}
    \label{fig:all}
\end{figure*}

\prettyref{subfiglcr:left} shows a typical example of red square;
\prettyref{subfiglcr:center} shows a particularly interesting specimen of green square,
while \prettyref{subfiglcr:right} shows a common and rather unremarkable blue square.

\end{document}

enter image description here

In this example, the tikz package is used instead of the graphicx package (used by the OP), in order to generate some placeholder pictures.