關閉 \appendices 開關並恢復正常的章節標籤

關閉 \appendices 開關並恢復正常的章節標籤

背景:

我正在使用該解決方案附加幾篇 IEEE 風格的論文這裡。

大多數論文都包含附錄,使用\appendices開關重新定義\thesection來建立附錄A、B、C 等。節現在是附錄 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}

在此輸入影像描述

相關內容