我正在编写一份较大的报告,需要帮助为附录命名章节。我想在文档的实际文本中(而不仅仅是在目录中)将“附录”作为附录章节编号的前缀添加进去。
ToC 正在正常运行:
附录章节编号不为:
代替:
一些东西
我希望它为:
附录 A:一些内容
同时保留附录的各个部分,就像在屏幕截图中一样。
我已附加 MWE:
\documentclass[11pt,twoside]{report}
\usepackage[a4paper]{geometry}
\raggedbottom
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{titlesec}
\titleformat{\chapter}{\bfseries\LARGE}{\thechapter~}{0em}{}
\usepackage[titletoc]{appendix}
\begin{document}
\pagenumbering{roman}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\tableofcontents
\chapter{Some Chapter}
\pagenumbering{arabic}
\setcounter{page}{1}
\chapter{Another Chapter}
\begin{appendices}
\chapter{Some Stuff}
\section{List of stuff}
\section{List of more stuff}
\section{List of even more stuff}
\chapter{More Stuff}
\section{Some equations}
\section{Some more equations}
\end{appendices}
\end{document}
答案1
\titleformat
您可以在 s的设置中插入条件\chapter
:
\documentclass[11pt,twoside]{report}
\usepackage[a4paper]{geometry}
\raggedbottom
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{titlesec}
\makeatletter
\newcommand{\setappendix}{Appendix~\thechapter:~}
\newcommand{\setchapter}{\thechapter~}
\titleformat{\chapter}{\bfseries\LARGE}{%
\ifnum\pdfstrcmp{\@currenvir}{appendices}=0
\setappendix
\else
\setchapter
\fi}{0em}{}
\makeatother
\usepackage[titletoc]{appendix}
\begin{document}
\pagenumbering{roman}
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\tableofcontents
\chapter{Some Chapter}
\pagenumbering{arabic}
\setcounter{page}{1}
\chapter{Another Chapter}
\begin{appendices}
\chapter{Some Stuff}
\section{List of stuff}
\section{List of more stuff}
\section{List of even more stuff}
\chapter{More Stuff}
\section{Some equations}
\section{Some more equations}
\end{appendices}
\end{document}
条件检查您是否在appendices
环境中并\chapter
使用 设置标题\setappendix
。否则,它使用 设置它\setchapter
。