我正在尝试实施所附的解决方案来编译附录。但是,我认为该解决方案会导致表格和图片编号在使用后隐藏章节编号(子附录)。
我认为这种现象是由新环境“子附录”以及图表和表格计数器的设置方式引起的。有人能帮我吗?下面,您可以找到 MWE 和来源。
最好的
丹尼尔
\documentclass[12pt]{book}
\renewcommand{\baselinestretch}{1.5}
\usepackage[toc,page]{appendix}
\usepackage{array}
\usepackage{amsmath,amsthm,verbatim,amssymb,amsfonts,amscd, graphicx}
%\usepackage[toc,page]{appendix}
\usepackage{booktabs}
%\usepackage{caption}
%\usepackage{cite}
\usepackage{eurosym}
\usepackage{float}
%\usepackage{graphics}
%\usepackage{hyperref}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{natbib}
\usepackage{natbib}
%\bibliographystyle{rusnat}
%\usepackage[]{natbib}
%\usepackage[authordate]{biblatex-chicago}
%\usepackage[authordate]{biblatex-chicago}
\setcitestyle{sort&compress,authoryear,open={(},close={)}}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{threeparttable}
\usepackage{xcolor}
\usepackage[tableposition=top]{caption}
\usepackage[section]{placeins}
\usepackage[multiple]{footmisc}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{pifont}
\usepackage[acronym]{glossaries}
\makeglossaries
\usepackage{longtable} % for 'longtable' environment
\usepackage{pdflscape} % for 'landscape' environment
\usepackage[hyphens]{url}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=black,
urlcolor=black,
citecolor=blue,
}
\usepackage{fancyhdr}
\pagestyle{fancy}
%\usepackage{fancychap}
\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{dsfont}
\usepackage{makecell}
\titleformat{\chapter}[display]
{\normalfont\Large\sffamily}
{%\titlerule[1pt]%
%\vspace{1pt}%
%\titlerule
\vspace{1pc}%
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}
%[\newpage] % creates the new page
\usepackage{tabularx}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
\vspace{1ex}
\captionsetup{justification={justified}, font={footnotesize,singlespacing}}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}
\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}
% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p $<$ 0.1, ** p $<$ 0.05, *** p $<$ 0.01.}}
\newcommand{\tablefont}{\fontsize{8pt}{10pt}\selectfont\centering}
% *****************************************************************
% Cnew column types
% *****************************************************************
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\defcitealias{BAMF2019}{BAMF, 2019}
\defcitealias{CDC2020}{CDC, 2020}
\defcitealias{RKI2020a}{RKI, 2020a}
\defcitealias{ba2020}{BA, 2020}
\defcitealias{Lancet2020}{The Lancet Global Health, 2020}
\defcitealias{UNHCR1951}{UNHCR, 1951}
\newcommand{\ie}{\textit{i}.\textit{e}., }
\newcommand{\eg}{\textit{e}.\textit{g}., }
\def\chapterthanks#1{\renewcommand{\thefootnote}{$\heartsuit$}%
\addtocounter{footnote}{-1}%
\footnote{#1}}
\makeatletter
\patchcmd{\@maketitle}{\newpage}{}{}{}
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3em}} % modified.
\let\l@table\l@figure
\makeatother
\fancyfoot{}
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
% End of subappendices environment
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithout{table}{section}
}
\begin{document}
%\input{sections/Title.tex}
\begin{titlepage}
\begin{center}
\vspace*{1cm}
{\LARGE Awesome stuff}
\vspace{2cm}
{\Large stuffy stuff}
\vspace{2cm}
{\Large More stuffy stuff
\vfill
%\includegraphics[width=0.4\textwidth]{university}
Authored by me}
\end{center}
\end{titlepage}
\tableofcontents
\listoffigures
\listoftables
\chapter[Initial stuff]{Initial stuff}
Interesting stuff.
\section{test}
\begin{table}[]
\caption{Test 1\label{tab:test1}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 2\label{tab:test2}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\chapter[Initial stuff 2]{Initial stuff}
Interesting stuff 2.
\section{test 2}
\begin{table}[]
\caption{Test 3\label{tab:test3}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 4\label{tab:test4}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\end{document}
编辑:我必须补充一下,我在评论中实现了解决方案。我直接在链接中提供的 MWE 中复制了错误。请在下面找到 MWE 2。
\documentclass{book}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{lipsum}
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithout{table}{section}
}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter[Initial stuff]{Initial stuff}
Interesting stuff.
\section{test}
\begin{table}[]
\caption{Test 1\label{tab:test1}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 2\label{tab:test2}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\chapter[Initial stuff 2]{Initial stuff}
Interesting stuff 2.
\section{test 2}
\begin{table}[]
\caption{Test 3\label{tab:test3}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 4\label{tab:test4}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 & \\
5 & 6 & 7 & 8 & \\
& & & & \\
& & & &
\end{tabular}
\end{table}
\end{subappendices}
\end{document}
答案1
我找到了一个解决方案。来源在这里:每章后附录 v2.0
答案是改变新的环境如下:
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithin{figure}{chapter}
\counterwithout{table}{section}
\counterwithin{table}{chapter}
}
就是这样。这就是答案。
丹尼尔