In my document, I have some figures in my appendix I want to reference in my text but the output of \ref{}
is only "Figure .2 shows…". It should be something like "Figure B.2".
Here's my minimal example:
\documentclass[bibliography=totoc,index=totoc,numbers=noenddot]{scrbook}
\usepackage[demo]{graphicx}
\begin{document}
\frontmatter
\include{Titel}
\tableofcontents
\mainmatter
Here is my text \ref{fig:XYZ}
\backmatter
\appendix
\renewcommand\thesection{\Alph{section}}
\chapter{Appendix}
\section{UML-Diagrams}
\begin{figure}[h]
\begin{center}
\includegraphics[width=15cm]{xyz.jpg}
\caption{\label{fig:XYZ}XYZ}
\end{center}
\end{figure}
\end{document}
Best Answer
You also need to redefine
\thefigure
to your own format. By defaultscrbook
removes the chapter number from it outside the main matter. I assume now you actually want the section number in it.Also note that you should use
\centering
not thecenter
environment in floats likefigure
. Then{figure}[h]
is never a good idea. If you don't want to make the figure float use an own environment (likecenter
which now is OK) instead and use\captionof{figure}{...}
for the caption (needs either thecaption
(big) orcapt-of
(small) package). Also, please put the\label
after\caption
, not inside it. It works both ways but this is better.