在下面的程式碼中,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}