在下面的代码中,figure
数字显示为1.1
。我怎样才能将figure
数字格式更改为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}
答案1
这是一个解决方案
\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}