我正在使用titlesec
带有pagestyles
选项的包来重新定义plain
和empty
页面样式。但是当编译下面的代码时,empty
页面使用了plain
页脚。
代码:
% Início do preâmbulo
\documentclass[a4paper,11pt,twoside]{book}
%% \usepackages diversos
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[brazilian]{babel}
\usepackage[top=30mm,left=20mm,right=20mm,bottom=20mm]{geometry}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{array}
\usepackage{float}
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage[clearempty,pagestyles]{titlesec}
%% Definições de fonte
\setmainfont{LiberationSerif-Regular.ttf}[BoldFont=LiberationSerif-Bold.ttf,ItalicFont=LiberationSerif-Italic.ttf,BoldItalicFont=LiberationSerif-BoldItalic.ttf]
\setsansfont{LiberationSans-Regular.ttf}[BoldFont=LiberationSans-Bold.ttf,ItalicFont=LiberationSans-Italic.ttf,BoldItalicFont=LiberationSans-BoldItalic.ttf]
\setmonofont{LiberationMono-Regular.ttf}[BoldFont=LiberationMono-Bold.ttf,ItalicFont=LiberationMono-Italic.ttf,BoldItalicFont=LiberationMono-BoldItalic.ttf]
\setstretch{1.15}
%% \setlenghts diversos
\setlength{\parindent}{1.25cm}
\setlength{\parskip}{6pt}
\setlength{\tabcolsep}{1mm}
\setlength{\columnsep}{5mm}
%% \setcounters diversos
\setcounter{secnumdepth}{-1}
\setcounter{tocdepth}{3}
%% Definições para o pacote hyperref
\hypersetup{linktoc=all,colorlinks=true,allcolors=black}
%% \renewcommands diversos
\renewcommand{\labelenumi}{\arabic{enumi}}
\renewcommand{\labelenumii}{\arabic{enumii}}
\renewcommand{\labelenumiii}{\arabic{enumiii}}
\renewcommand{\labelenumiv}{\arabic{enumiv}}
\addto\captionsbrazilian{\renewcommand{\contentsname}{Índice}}
%% Definições de novos estilos de página
\renewpagestyle{empty}{%
\setheadrule{0pt}%
\setfootrule{0pt}%
\sethead[][][]{}{}{}%
\setfoot[][][]{}{}{}%
}%
\renewpagestyle{plain}[\scriptsize]{%
\setheadrule{0pt}%
\setfootrule{1pt}%
\footrule{}%
\setfoot[][ - \thepage{} - ][]{}{ - \thepage{} - }{}%
}%
\newpagestyle{agradecimento}[\scriptsize]{%
\setheadrule{0pt}%
\setfootrule{1pt}%
\footrule{}%
\setfoot[][ - \thepage - ][]{}{ - \thepage - }{}%
}%
% Fim do preâmbulo
% Início do documento
\begin{document}
\pagestyle{empty}
\pagenumbering{gobble}
\chapter[Capa]{}
\begin{center}
\vfill
{\bfseries\Huge Thalassia\par}
\vspace{1em}
{\Large Um mundo de exploração e aventuras para \emph{Dungeon World}\par}
\vspace{1em}
por Lu Cavalheiro\par
\vfill
{\small Licença: Creative Commons BY-SA 4.0\par}
{\small 2020\par}
\vfill
\hspace{0pt}
\end{center}
\clearpage
\pagestyle{agradecimento}
\pagenumbering{Alph}
\chapter{Agradecimentos}
\end{document}
如图所示,第 1 页(用作标题页)具有与第 2 页相同的页脚,但第 1 页设置为empty
页面样式,而第 2 页则设置plain
为。如何防止第 1 页使用第 2 页的页脚?
答案1
不要重新定义empty
页面样式——只需\thispagestyle{empty}
在第一个 之后使用 \chapter
即可。此外,如果您想要无头规则,则不必使用\setheadrule{0pt}
:与 相反fancyhdr
,您不必使用\headrule
。
此外,总是hyperref
最后加载(极少数例外 - 最值得注意的是cleveref
),并且建议使用 \documentclass 加载语言选项,以便所有相关语言的包都能得到通知。
\documentclass[a4paper,11pt,twoside, brazilian]{book}
%% \usepackages diversos
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[top=30mm,left=20mm,right=20mm,bottom=20mm]{geometry}
\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{array}
\usepackage{float}
\usepackage[clearempty ,pagestyles]{titlesec}%
\usepackage{fontspec}
\usepackage{setspace}
\usepackage{hyperref}
%% Definições de fonte
\setmainfont{LiberationSerif-Regular.ttf}[BoldFont=LiberationSerif-Bold.ttf,ItalicFont=LiberationSerif-Italic.ttf,BoldItalicFont=LiberationSerif-BoldItalic.ttf]
\setsansfont{LiberationSans-Regular.ttf}[BoldFont=LiberationSans-Bold.ttf,ItalicFont=LiberationSans-Italic.ttf,BoldItalicFont=LiberationSans-BoldItalic.ttf]
\setmonofont{LiberationMono-Regular.ttf}[BoldFont=LiberationMono-Bold.ttf,ItalicFont=LiberationMono-Italic.ttf,BoldItalicFont=LiberationMono-BoldItalic.ttf]
\setstretch{1.15}
%% \setlenghts diversos
\setlength{\parindent}{1.25cm}
\setlength{\parskip}{6pt}
\setlength{\tabcolsep}{1mm}
\setlength{\columnsep}{5mm}
%% \setcounters diversos
\setcounter{secnumdepth}{-1}
\setcounter{tocdepth}{3}
%% Definições para o pacote hyperref
\hypersetup{linktoc=all,colorlinks=true,allcolors=black}
%% \renewcommands diversos
\renewcommand{\labelenumi}{\arabic{enumi}}
\renewcommand{\labelenumii}{\arabic{enumii}}
\renewcommand{\labelenumiii}{\arabic{enumiii}}
\renewcommand{\labelenumiv}{\arabic{enumiv}}
\addto\captionsbrazilian{\renewcommand{\contentsname}{Índice}}
%% Definições de novos estilos de página
\renewpagestyle{plain}[\scriptsize]{%
\setfootrule{1pt}%
\footrule{}%
\setfoot[][ - \thepage{} - ][]{}{ - \thepage{} - }{}%
}%
\newpagestyle{agradecimento}[\scriptsize]{%
\setfootrule{1pt}%
\footrule{}%
\setfoot[][ - \thepage - ][]{}{ - \thepage - }{}%
}%
% Fim do preâmbulo
\usepackage{lipsum}
% Início do documento
\begin{document}
%\pagenumbering{gobble}
\chapter[Capa]{}\thispagestyle{empty}
\begin{center}
\vfill
{\bfseries\Huge Thalassia\par}
\vspace{1em}
{\Large Um mundo de exploração e aventuras para \emph{Dungeon World}\par}
\vspace{1em}
por Lu Cavalheiro\par
\vfill
{\small Licença: Creative Commons BY-SA 4.0\par}
{\small 2020\par}
\vfill
\hspace{0pt}
\end{center}
\chapter{Agradecimentos}
\pagestyle{agradecimento}
\pagenumbering{Alph}
\end{document}