각 장 v2.0 이후의 부록

각 장 v2.0 이후의 부록

질문 답변과 마찬가지로 책의 각 장 뒤에 2~3개의 섹션이 있는 부록을 추가하고 싶습니다.여기.

거기에 제공된 대답은 훌륭하지만 그림 번호 매기기 등에 바람직하지 않은 영향을 미칩니다. 수업에서 book그림은 내가 좋아하는 장별 방식(예: 1.1, 1.2,...,2.1, 2.2)으로 번호가 매겨져 있지만 대답은 새로운 subappendices환경을 사용한 후 모든 장에서 섹션별 번호 매기기로 재설정합니다. 이로 인해 이상한 섹션별 번호 매기기가 생성됩니다. - 1.1, 1.2(1장 좋음), 하위 부록, 2.1, 2.2(첫 번째 섹션의 2장 그림), 2.1, 2.2 (두 번째 섹션의 ch 2 숫자). 번호 매기기를 장별 번호로 재설정하려면 어떻게 해야 합니까?

MWE는 다음과 같습니다.

\documentclass{book}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{float}


\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}

\begin{document}

\tableofcontents

\chapter{Test Chapter One}
\section{A regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Another regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{subappendices}
\section{Some title for an appendix}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Some title for an appendix}
\lipsum[4]
\end{subappendices}

\chapter{Test Chapter Two}
\section{A regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Another regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\end{document}

답변1

잘 된 것은 subappendices환경의 끝을 다음과 같이 정의하는 것입니다.

\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithin{figure}{chapter}
\counterwithout{table}{section}
\counterwithin{table}{chapter}
}

전체 예:

\documentclass{book}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{float}


\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}
}

\begin{document}

\tableofcontents

\chapter{Test Chapter One}
\section{A regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Another regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{subappendices}
\section{Some title for an appendix}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Some title for an appendix}
\lipsum[4]
\end{subappendices}

\chapter{Test Chapter Two}
\section{A regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\section{Another regular section}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\begin{figure}; 
\begin{tikzpicture}; \draw (0,0) --(1,2);\end{tikzpicture}; \caption{some caption} 
\end{figure}

\end{document}

답변2

이 두 줄을 변경하세요

\counterwithin{figure}{section}
\counterwithin{table}{section}

에게

\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}

또는 완전히 생략하십시오(기본값).

관련 정보