NewFuture / NKThesis

南开大学硕士毕业论文/博士论文模板 (Latex Template for Nankai University)
https://nkthesis.newfuture.cc
MIT License
127 stars 45 forks source link

想问一下该模板如何添加附录? #24

Closed BBBYmBYYY closed 1 year ago

BBBYmBYYY commented 1 year ago

/appendix命令编译出错 “Paragraph ended before \@chapter was complete.”

以下是模板内tex目录下appendices文件内进行的测试。

% !TeX root = ../main.tex % -- coding: utf-8 --

\appendix

\section{test}

BBBYmBYYY commented 1 year ago

问题已解决。本模板的附录命令定义形式为

\def\appendix{
        \if@firstappendix
     \setcounter{chapter}{0}%
     \setcounter{section}{0}%
     \renewcommand\@chapapp{Appendix}
     \typeout{....\AppendicesTotal...}
     \ifnum\AppendicesTotal=1
         \renewcommand\chaptername{\appendixnamenonumber}
     \else
         \renewcommand\chaptername{\appendixname}
     \fi
     \@firstappendixfalse
  \fi
  \chapter}%

因此,常规的\appendix形式无效。而应该将\appendix作为类似于\chapter命令的形式来使用,它至少需要一个参数,形如\appendix{Appendix Test}.

使用该命令后能够正常生成附录。但现在的模板经测试存在以下两个问题:

  1. 附录不能正常编号。目前可以通过将上述代码中的\appendixnonumber\appendixname修改为\appendixnamenonumber\Alph{chapter}来实现附录编号.
  2. 附录内公式、定理等不符合写作规范的编号形式(需要编号为公式A1,定理A1等等)。解决方式可以通过在定义\appendix命令时加入以下命令来实现:
    \renewcommand\theequation{\Alph{chapter}\arabic{equation}}
    \renewcommand{\theTheorem}{\Alph{chapter}\arabic{Theorem}}
    \renewcommand{\thefigure}{\Alph{chapter}\arabic{figure}}
    \renewcommand{\thetable}{\Alph{chapter}\arabic{table}}
TCLiuu commented 1 year ago

我也做过类似的修改,但是这样会导致附录部分书签对应的跳转页码不正确,请问你是否碰到了同样的问题?

BBBYmBYYY commented 1 year ago

我也做过类似的修改,但是这样会导致附录部分书签对应的跳转页码不正确,请问你是否碰到了同样的问题?

不太明确你指的什么,如果你说的是正文引用"附录A"的超链接不能跳转到对应位置的话,我现在也有这样的问题。但是这个并不是硬性的格式要求,所以我没管

LTianyyi commented 6 months ago

今天也遇到了这个问题,我已经解决掉并且测试成功了。 其原因是因为chapter被重新计数为0了,导致索引跳转错误(如从目录点击却跳转到第一章,对应内容也是会被跳转到第一章)。 我的解决方法是在在NKThesis.sty里修改一些内容:

  1. 增加一个计数器appendixstart(或者喜欢的名字,后面保持一致就好),用来标记附录编号,加在第二个\if@NKT@English的前一行:
    \newcounter{appendixstart}
  2. 修改原来的标题模式,注意使用\appendixstart来为附录编号,而不是\chapter。将第二个\if@NKT@English对应内容修改为:
    \if@NKT@English
    \def\chaptername{Chapter \arabic{chapter}}
    \def\thesection{\arabic{chapter}.\arabic{section}}
    \def\thesubsection{\arabic{chapter}.\arabic{section}.\arabic{subsection}}
    \def\appendixname{Appendix \Alph{appendixstart}}
    \def\contentsname{CONTENTS}
    \def\appendixnamenonumber{Appendix}
    \def\nkrefname{References}
    \def\tablename{Table}
    \def\figurename{Figure}
    \def\NKT@proof{Proof}
    \else
    \def\chaptername{第\CJKnumber{\arabic{chapter}}章}
    \def\thesection{第\CJKnumber{\arabic{section}}节}
    \def\thesubsection{\arabic{chapter}.\arabic{section}.\arabic{subsection}}
    \def\appendixname{附录\Alph{appendixstart}}
    \def\contentsname{目录}
    \def\appendixnamenonumber{附录}
    \def\nkrefname{参考文献}
    \def\tablename{表}
    \def\figurename{图}
    \def\NKT@proof{证明}
    \fi
  3. 更新\appendix的模板,包括章节计数、公式图表编号等等。注意不能重设\chapter(否则会导致书签跳转错误,因为这里的内容会被链接到第一章,包括目录也是),利用\appendixstart对标题进行编号。\def\appendix对应内容修改为:
    \def\appendix{
    \if@firstappendix
     \setcounter{appendixstart}{0}
    %  \setcounter{chapter}{0}%
     \setcounter{section}{0}%
     \setcounter{equation}{0}%
     \renewcommand\@chapapp{Appendix}
     \typeout{....\AppendicesTotal...}
     \ifnum\AppendicesTotal=1
         \renewcommand\chaptername{\appendixnamenonumber}
         \renewcommand{\theequation}{\Alph{appendixstart}.\arabic{equation}} 
         \renewcommand{\thefigure}{\Alph{appendixstart}.\arabic{figure}}
         \renewcommand{\thetable}{\Alph{appendixstart}.\arabic{table}}
     \else
         \renewcommand\chaptername{\appendixname}
         \renewcommand{\theequation}{\Alph{appendixstart}.\arabic{equation}}
         \renewcommand{\thefigure}{\Alph{appendixstart}.\arabic{figure}}
         \renewcommand{\thetable}{\Alph{appendixstart}.\arabic{table}}
     \fi
     \@firstappendixfalse
    \fi
    \stepcounter{appendixstart}
    \chapter}%
  4. 更新\AppendicesTotal的统计方式(不更改的话,会导致绪论、...、总结都会被算作附录的数量),使用\theappendixstart而不是\thechapter计算。即第二个\AtEndDocument对应部分更改为:
    \AtEndDocument{
    \if@firstappendix
    \else
    % \immediate\write\@auxout{\string\AppendicesNumber{\thechapter}}
    \immediate\write\@auxout{\string\AppendicesNumber{\theappendixstart}}
    \fi}

经过上述步骤更改即可,我在自己的论文上测试是没有问题的。