我正在编写一份不需要太多形式主义的文档,但我想实现以下编号系统:
1 Section
Table 1: Caption
Figure 1: Caption
1.1 Subsection
Table 1.1: Caption
Figure 1.1: Caption
有什么建议吗?
答案1
如果每个部分中有多个浮点数,则附加b
, .. 。c
\documentclass{article}
\makeatletter
\@addtoreset{table}{subsection}
\@addtoreset{figure}{subsection}
\@addtoreset{table}{section}
\@addtoreset{figure}{section}
\renewcommand\thefigure{%
\ifnum\value{subsection}=0 \thesection\else\thesubsection\fi\ifnum\value{figure}>1 \alph{figure}\fi}
\renewcommand\thetable{%
\ifnum\value{subsection}=0 \thesection\else\thesubsection\fi\ifnum\value{table}>1 \alph{table}\fi}
\makeatother
\begin{document}
\listoftables
\section{zzz}
a
\begin{table}[!htp]TTTT\caption{tt}\end{table}
b
\begin{figure}[!htp]FFF\caption{ff}\end{figure}
\subsection{www}
a
\begin{table}[!htp]TTTT\caption{tt tt}\end{table}
b
\begin{figure}[!htp]FFF\caption{ff ff}\end{figure}
aa
\begin{table}[!htp]TTTT\caption{tt tt tt}\end{table}
bb
\begin{figure}[!htp]FFF\caption{ff ff ff}\end{figure}
\end{document}