写论文的时候,附录需要重新编号为A.1,A.2怎么办?
这里有两个坑会踩:
- Algorithm的重新编码
- 正文引用附录链接错误,跳转到正文
第1个问题
我在正文中用的是\usepackage[ruled,linesnumbered]{algorithm2e}
不要setcounter{algorithm},要用{algocf},见下:
解决方案:
\appendix
\section{Appendix}
\setcounter{table}{0} %从0开始编号,显示出来表会A1开始编号
\setcounter{figure}{0}
\setcounter{section}{0}
\setcounter{equation}{0}
\setcounter{algocf}{0} % 注意重新编码algorithm的用法!!!
%定义编号格式,在数字序号前加字符“A."
\renewcommand\thetable{A.\arabic{table}}
\renewcommand\thefigure{A.\arabic{figure}}
\renewcommand\thesection{A\arabic{section}}
\renewcommand\theequation{A.\arabic{equation}}
\renewcommand\thealgocf{A.\arabic{algocf}} % 注意重新编码algorithm的用法!!!
这个时候问题2来了:
我们发现正文引用附录Appendix表格的时候,如:
Figure \ref{app:fig}
会出现问题:即Figure A1链接到的是正文中的Figure 1。
怎么解决这个问题?
继续添加代码:
\appendix
\section{Appendix}
\setcounter{table}{0}
\setcounter{figure}{0}
\setcounter{section}{0}
\setcounter{equation}{0}
\setcounter{algocf}{0}
\renewcommand\thetable{A.\arabic{table}}
\renewcommand\thefigure{A.\arabic{figure}}
\renewcommand\thesection{A\arabic{section}}
\renewcommand\theequation{A.\arabic{equation}}
\renewcommand\thealgocf{A.\arabic{algocf}}
################ 新增代码 ################
\renewcommand*{\theHtable}{\thetable}
\renewcommand*{\theHfigure}{\thefigure}
\renewcommand*{\theHequation}{\theequation}
\renewcommand*{\theHsection}{\thesection}
\renewcommand*{\theHalgocf}{\thealgocf}
################ 新增代码 ################
添加完了这个代码以后,就发现即Figure A.1链接定位到了的是附录中的Figure A.1。
成功!
8963

被折叠的 条评论
为什么被折叠?



