2

In the following code the figure number is shown as 1.1. How can I change the figure number format to 1-1?

\documentclass{book}
\usepackage{graphicx}
\usepackage{caption}


\begin{document}
\chapter{One}
test
\begin{figure}[ht!]
\centering
 \includegraphics[scale=0.5]{10.png} \caption{} \label{handle}
\end{figure}

Figure \ref{handle}.
\end{document}
Mico
  • 506,678
Minimus Heximus
  • 715
  • 6
  • 19

1 Answers1

4

Here is a solution

\documentclass{book}
\usepackage{graphicx}
\usepackage{caption}
\renewcommand\thefigure{\ifnum \value{chapter}>0 \thechapter-\fi \arabic{figure}}

\begin{document}
\chapter{One}
test
\begin{figure}[ht!]
\centering
 \includegraphics[scale=0.5]{myfoto} \caption{bla} \label{handle}
\end{figure}

Figure \ref{handle}.
\end{document}
touhami
  • 19,520