我试图让普通章节和附录章节使用相同的章节标题样式,但在附录标题前添加单词“附录”,因为附录标题前只显示字母。目前,章节标题样式使用以下代码定义:
% Chapter title settings
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\Huge\bfseries\filcenter}
{{\fontsize{50pt}{1em}\vspace{-4.2ex}\selectfont \textnormal{\thechapter}}}{1ex}{}[]
我已设法使其在目录中发挥作用,但不在附录标题中发挥作用。
附录代码如下:
\usepackage[titletoc]{appendix}
% APPENDICES
\cleardoublepage
\appendix
\setcounter{page}{1}
\pagenumbering{Roman} % Capitalized roman numbering starting from I (one)
\begin{appendices}
\input{include/backmatter/Appendix_1}
\end{appendices}
例子:
\documentclass[12pt,a4paper,twoside,openright]{report}
\usepackage[utf8]{inputenc}
\usepackage[titletoc]{appendix}
\usepackage{moreverb} % List settings
\usepackage{textcomp} % Fonts, symbols etc.
\usepackage{lmodern} % Latin modern font
\usepackage{helvet} % Enables font switching
\usepackage[T1]{fontenc} % Output settings
\usepackage[english]{babel} % Language settings
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\Huge\bfseries\filcenter}
{{\fontsize{50pt}{1em}\vspace{-4.2ex}\selectfont \textnormal{\thechapter}}}{1ex}{}[]
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\space#1}{}}
% Select one-sided (1) or two-sided (2) page numbering
\def\layout{2} % Choose 1 for one-sided or 2 for two-sided layout
% Conditional expression based on the layout choice
\ifnum\layout=2 % Two-sided
\fancyhf{}
\fancyhead[LE,RO]{\nouppercase{ \leftmark}}
\fancyfoot[LE,RO]{\thepage}
\fancypagestyle{plain}{ % Redefine the plain page style
\fancyhf{}
\fancyfoot[LE,RO]{\thepage} % Added for the extra even pages
\renewcommand{\headrulewidth}{0pt}}
\fancyfoot[LE,RO]{\thepage}
\else % One-sided
\fancyhf{}
\fancyhead[C]{\nouppercase{ \leftmark}}
\fancyfoot[C]{\thepage}
\fi
\makeatletter
\setlength{\@fptop}{0pt}
\makeatother
\title{Test}
\author{Mr Need Help}
\date{\today}
\begin{document}
\maketitle
\pagenumbering{roman}
\cleardoublepage
\tableofcontents
\setcounter{page}{1}
\pagenumbering{arabic} % Arabic numbering starting from 1 (one)
\setlength{\parskip}{0pt plus 1pt}
\chapter{Introduction}
\chapter{Method}
% APPENDICES
\cleardoublepage
\appendix
\setcounter{page}{1}
\pagenumbering{Roman} % Capitalized roman numbering starting from I (one)
\begin{appendices}
\chapter{Test 1}
\chapter{Test 2}
\end{appendices}
\end{document}
答案1
该命令不仅可以在前言中使用,还\titleformat
可以在环境中使用document
。因此,您可以在附录前插入以下命令:
\titleformat{\chapter}[display]
{\Huge\bfseries\filcenter}
{{\fontsize{50pt}{1em}\vspace{-4.2ex}\selectfont
\textnormal{\appendixname\thechapter}}}{1ex}{}[]
顺便一提:
- 在
report
或book
类中,附录是\chapter
s并且数据包appendix
是TTBOMK,没用,\appendix
声明应该足够了。 - 当您使用类选项
twoside,openright
并定义自己的标题时,您可以更舒适地切换到book
类,在那里您还可以从声明中受益\frontmatter
,\mainmatter
从而消除手动更改页码(当然,附录除外)。