GeneralSeparate numbering for different reference types

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
JefVL
Posts: 13
Joined: Sat Mar 22, 2014 10:27 pm

Separate numbering for different reference types

Post by JefVL »

Hi all,

I've found some great help with a few questions already on this forum, and I hope you can help me again this time. I've searched the web for a solution, but I can't find anything specific for my issue (perhaps I'm just searching the wrong keywords).

Here's my problem: in my thesis, I'd like to refer to a picture that's too large to place in the text body, and I can't make it smaller because it's already kind of below its minimal size, so I placed it in an appendix. It's only the first appendix in my thesis so far, but more might follow. Now, when I want to refer to that picture, I mention this in my code:

Code: Select all

\documentclass{article}
\usepackage{hyperref}
\begin{document}
TEXT
Picture~\ref{fig:abc} in appendix~\ref{app:def} shows...
MORE TEXT
\section{Appendix}
\subsection*{Figure~\ref{fig:abc}}
\phantomsection
\begin{figure}[htbp]
	\centering
		\includegraphics[scale=0.085]{abc.pdf}
	\caption{My caption}
	\label{fig:abc}
\end{figure}
\label{app:def}
\end{document}
When I compile this, I get the text: "Figure 7 in appendix 8 shows..."

I already know that it's writing "appendix 8" because I've placed my \label in the appendix section, which is the 8th section in my thesis.

My question is: is it possible to tell latex to use a separate numbering for my appendix so that it would show "Figure 7 in appendix 1"?

Thanks in advance!

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Separate numbering for different reference types

Post by Johannes_B »

There is a simple switch called \appendix. See the example below.

In an example, you usually don't want your stuff to float around. You can put everything in a minipage and set the caption using capt-of.

Code: Select all

\documentclass{article}
\usepackage{blindtext}
\usepackage{capt-of}
\usepackage{hyperref}
\begin{document}
TEXT
Picture~\ref{fig:abc} in appendix~\ref{app:def} shows...
\blindtext

\appendix
\section{Appendix}
\subsection*{Figure~\ref{fig:abc}}
\phantomsection
\begin{figure}[htbp]
        \centering
                \rule{7cm}{6cm}
        \caption{My caption}
        \label{fig:abc}
\end{figure}
\label{app:def}
\noindent\begin{minipage}{\textwidth}
\begin{center}
\rule{7cm}{4cm}
\captionof{figure}{A nice little caption}
\end{center}
\end{minipage}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
JefVL
Posts: 13
Joined: Sat Mar 22, 2014 10:27 pm

Re: Separate numbering for different reference types

Post by JefVL »

Thanks! I had no idea there was an \appendix command, that did the trick. The minipage caused some strange effects though (a black rectangle showing on the first appendix page with a small caption, and the actual picture being moved to the next page), so I left that part out. I'm already happy that the reference is correct now, so thank you very much!
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Separate numbering for different reference types

Post by Johannes_B »

The contents of the minipage were just a small example on how to set a caption. The black rectangle was substitute for a figure, table etc. That should not go into your real document ;-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
JefVL
Posts: 13
Joined: Sat Mar 22, 2014 10:27 pm

Re: Separate numbering for different reference types

Post by JefVL »

Oh, I see. Well, thanks for the help and the example :) I should be fine now (for a while at least :lol:)
Post Reply