Graphics, Figures & Tablessubfigure | References to Sub-figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
maloszybki
Posts: 1
Joined: Wed Nov 14, 2012 6:31 pm

subfigure | References to Sub-figures

Post by maloszybki »

Hi,

I have this code:

Code: Select all

\begin{figure}[!h]
	\begin{center}
		\subfigure[gwiazda]{
			\includegraphics[width=0.4\textwidth]{img/silnik-gwiazda.eps}
			\label{fig:silnik_sub_gwiazda}
		}
		\subfigure[trójkąt]{
			\includegraphics[width=0.4\textwidth]{img/silnik-trojkat.eps}
			\label{fig:silnik_sub_trojkat}
		}
	\end{center}
	\caption{Schemat elektryczny trójfazowego silnika bezszczotkowego \subref{fig:silnik_sub_gwiazda} -- gwiazda; \subref{fig:silnik_sub_trojkat} -- trójkąt (delta)}
	\label{fig:silnik}
\end{figure}

(rysunek \ref{fig:silnik}) | (rysunek \ref{fig:silnik_sub_gwiazda})
And here is rendered text from last line:
(rysunek 1) | (rysunek 2.1(a))
I expected another numeration. How I can get this:
(rysunek 1) | (rysunek 1(a))
I know I can use combination of \ref and \subref, but this is wrong way.

My class file is attached.
Attachments
main.cls
(9.9 KiB) Downloaded 146 times
Last edited by localghost on Wed Nov 14, 2012 7:02 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

jbgrad
Posts: 5
Joined: Sat Nov 17, 2012 4:31 am

subfigure | References to Sub-figures

Post by jbgrad »

I am no Latex expert, but I've successfully done the following to a similar issue in my code. I added to the preamble:

Code: Select all

\renewcommand{\thesubfigure}{\arabic{figure}(\alph{subfigure})}
You'll notice a similar line in the file you attached:

Code: Select all

\renewcommand\thefigure{\@arabic\c@figure}
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

subfigure | References to Sub-figures

Post by cgnieder »

Hi maloszybki,

Welcome to the LaTeX community!

After I removed the dvips option to the graphicx package in main.cls (which isn't needed anyway, »graphicx« is quite possible of determining the right driver) I got the following MWE (Infominimal working example) running. (Note that I also replaced the {center} environment with \centering since the environment adds additional spacing.)

Code: Select all

\RequirePackage[demo]{graphicx}% this is only to black out the pictures as I don't have the eps files availyble
\documentclass{main}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{subfigure}
\begin{document}

\begin{figure}[!h]
  \centering
  \subfigure[gwiazda]{
    \includegraphics[width=0.4\textwidth]{img/silnik-gwiazda.eps}
    \label{fig:silnik_sub_gwiazda}
  }
  \subfigure[trójkąt]{
    \includegraphics[width=0.4\textwidth]{img/silnik-trojkat.eps}
    \label{fig:silnik_sub_trojkat}
  }
  \caption{Schemat elektryczny trójfazowego silnika bezszczotkowego \subref{fig:silnik_sub_gwiazda}
    -- gwiazda; \subref{fig:silnik_sub_trojkat} -- trójkąt (delta)}
  \label{fig:silnik}
\end{figure}

(rysunek \ref{fig:silnik}) | (rysunek \ref{fig:silnik_sub_gwiazda})

\end{document}
Apart from complaining that subfigure is obsolete (it has been superseded by subfig and even more recently by subcaption which is also better suiting to the caption package that is loaded in the class file) I cannot reproduce what you're saying:
subfigure.png
subfigure.png (12.11 KiB) Viewed 2518 times
So please add a Infominimal working example (maybe based on mine) that reproduces the unwanted behaviour.

Regards
site moderator & package author
Post Reply