关闭 \appendices 开关并恢复正常的部分标签

关闭 \appendices 开关并恢复正常的部分标签

背景:

我正在附加几篇使用该解决方案的 IEEE 风格论文这里。

大多数论文都包含附录,使用\appendices开关重新定义\thesection来创建附录 A、B、C 等。我的问题是,当在文档中引入新论文时,\thesection 从未重新定义,因此应该标记为第 1 节的内容现在是附录 A。

问题:

我如何重新定义 \thesection 以恢复 ieeetran 样式的正常章节标记?

答案1

我允许自己厚颜无耻地窃取解决方案 在目录中包含 \maketitle 来编译 IEEE 文章的“书”来自提供它的那个奇怪的家伙 (;-))

IEEEtran限制性很强,因为它不允许在or命令sections之后使用。这样,它定义了宏\appendix\appendices

\def\@IEEEdestroythesectionargument#1

发出警告/错误。可以通过插入已保存的部分宏\let\LaTeXStandardSection来代替警告来解决此问题。(小警告:但是,它不适用于带有可选参数的部分 --> 更好的方法:修补命令等\appendix

\thesection计数器格式宏必须在末尾恢复\maketitle

快速而肮脏的方法重新定义\appendices等等,这样它除了重置结构化级别计数器的计数器格式之外不执行任何其他操作。

\documentclass[journal]{IEEEtran}

\usepackage{etoolbox}%
\usepackage{xpatch}
\usepackage{blindtext}
\usepackage{tocloft}%

\newlength{\articlesectionshift}%
\setlength{\articlesectionshift}{10pt}%
\addtolength{\cftsecindent}{\articlesectionshift}%

\let\LaTeXStandardSection\section
\let\LaTeXStandardTheSection\thesection
\let\LaTeXStandardTheSubSection\thesubsection
\let\LaTeXStandardTheSubSubSection\thesubsubsection
\let\LaTeXStandardTheParagraph\theparagraph


\makeatletter
\newcounter{titlecounter}

\xpretocmd{\maketitle}{\ifnumgreater{\value{titlecounter}}{1}}{\clearpage}{}{} % Well, this is lazy at the end ;-)
\xpatchcmd{\maketitle}{\let\maketitle\relax\let\@maketitle\relax}{\refstepcounter{titlecounter}\begingroup
  \addtocontents{toc}{\begingroup\addtolength{\cftsecindent}{-\articlesectionshift}}%
  \addcontentsline{toc}{section}{\protect{\numberline{\thetitlecounter}{\@title~ \@author}}}%
  \addtocontents{toc}{\endgroup}
}{%
  \typeout{Patching was successful}
}{%
  \typeout{patching failed}
}%

\def\@IEEEdestroythesectionargument#1{\LaTeXStandardSection{#1}}%


\xapptocmd{\maketitle}{%
\renewcommand{\thesection}{\LaTeXStandardTheSection}%
\renewcommand{\thesubsection}{\LaTeXStandardTheSubSection}%
\renewcommand{\thesubsubsection}{\LaTeXStandardTheSubSubSection}%
\renewcommand{\theparagraph}{\LaTeXStandardTheParagraph}%
}{}{}%


\@addtoreset{section}{titlecounter}

\makeatother
\begin{document}
\onecolumn
\tableofcontents
\twocolumn        



% Title and Author information  Paper 1
\title{Title 1}
\author{Author 1}
% Make the title area
\maketitle

\section{First}
\subsection{First subsection of 1st section}%
\subsection{2nd subsection of 1st section}%
\subsection{3rd subsection of 1st section}%
\subsection{4th subsection of 1st section}%

\blindtext[10]
\section{Two}
\subsection{First subsection of 2nd section}%
\appendix
\section{First of Appendix}

% Title and Author information  Paper 2
\title{Title 2}
\author{Author 2}
% Make the title area
\maketitle
\section{First from second paper}
\subsection{First subsection of 2nd section of 2nd article}%

\blindtext[20]

%$ Paper Content

\end{document}

在此处输入图片描述

相关内容