I have a figure with 3 subfigures. I used the \ref{fig:2}
in my text and I got 2a. Can anyone knows how to make it 2(a) instead of 2a?
Below is an example of my code:
\begin{document}
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{graph1.jpg}
\caption{$y=x$}
\label{fig:1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{graph2.jpg}
\caption{$y=sinx$}
\label{fig:2}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{graph3.jpg}
\caption{$y=cosx$}
\label{fig:3}
\end{subfigure}
\caption{Three simple graphs}
\label{fig:three graphs}
\end{figure}
\end{document}
With Thanks
Best Answer
You can just do
Here's a complete example; notice that
\hfill
should go next to\end{subfigure}
and thatsinx
should be\sin x
(similarly for\cos x
).See Change format of reference to a subfigure for other customizations.