
我想知道如何在 setcounter 命令中寫入非整數。我正在寫一份報告,因此數字的數字不是 1、2、3,而是 1.1、1.2、1.3(在第一章)。
我嘗試了該命令\setcounter{figure}{1.14}
,但似乎 LaTeX 無法管理它,因為該數字不是整數。我怎樣才能克服這個問題?
\renewcommand{\thefigure}{\arabic{figure}}
在 setcounter 之後,我使用了定義為 的指令\renewcommand{\figurename}{Figura}
。
答案1
在 LaTeX 中,價值計數器的——比如說mycounter
——必須是一個整數。這個計數器的方式是排版是受宏觀調控的\themycounter
。此巨集可以包含有關計數器的數字表示形式的資訊 - 預設情況下,可以在阿拉伯數字(1
、2
等)、大寫和小寫羅馬數字(I
、II
等)以及大寫和小寫字母(a
、b
等)之間進行選擇。 -- 以及該計數器是否應該以其他項目作為前綴,例如章節號。
這是一個實用但稍顯做作的範例。
\documentclass{report}
\usepackage[italian]{babel}
% reset the 'figure' counter each time 'chapter' counter is changed:
\counterwithin{figure}{chapter} % (that's actually the default)
% going slightly overbord:
\renewcommand{\thefigure}{\Roman{chapter}.\alph{figure}}
\begin{document}
\setcounter{chapter}{5}
\setcounter{figure}{14}
Numeric value of \texttt{chapter} counter: \arabic{chapter}
Numeric value of \texttt{figure} counter: \arabic{figure}
\begin{figure}[ht] \caption{AAA} \end{figure}
\begin{figure}[hh] \caption{BBB} \end{figure}
\begin{figure}[hh] \caption{CCC} \end{figure}
\end{document}