
Atualmente, estou tentando configurar um documento para um relatório de projeto. Estou tendo dificuldades com os cabeçalhos e rodapés.
Eu gostaria de ter orodapé em todas as páginase o rodapé deve ficar parecido com a imagem mostrada abaixo.
Para conseguir esse rodapé, estou usando atualmente o fancyhdr
pacote com oestilo de página sofisticadoconforme mostrado no trecho de código abaixo.
\pagestyle{fancy}
%% FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER
\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION
\fancyfoot[R]{\small \today} % TODAY'S DATE
\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE
O problema que estou encontrando no rodapé é no sumário (coloquei \thispagestyle{fancy}
ao lado do sumário e de todos os capítulos para tentar obter os cabeçalhos e rodapés). OÍndiceédistribuídos em 2 páginas, a primeira página possui apenas o número da página para o rodapé, enquanto asegunda páginatem ocabeçalho e rodapé corretos.
OCabeçalho e rodapé do sumário para ambas as páginasdeve ser semelhante à imagem mostrada abaixo.
O cabeçalho é onde fica complicado. Para o cabeçalho, exijo todos osassunto principal(tudo antes do Capítulo 1) para ter oTítulo da seçãonolado direitodo cabeçalho e as letras devem ser exatamente iguais às letras do título (ou seja,não capitalizadoenão em itálico). O cabeçalho TOC (mostrado acima) é um exemplo do que quero dizer. Quanto aos capítulos, gostaria que a página do primeiro capítulo não tivesse cabeçalho e apenas o rodapé especificado acima. Para as demais páginas do capítulo, gostaria do capítulo à esquerda (Formato: Capítulo # - Nome do Capítulo) e a seção à direita (Formato: # Nome da Seção) do cabeçalho.
O cabeçalho e rodapé doprimeira página do capítulodeve se parecer com a imagem mostrada abaixo.
O cabeçalho e rodapé dopáginas restantes do capítulodeve ser semelhante à imagem mostrada abaixo (ignore o fato de ter mostrado a primeira página do capítulo).
Outra dificuldade que encontrei com o cabeçalho é que o cabeçalho do apêndice tem o Capítulo A em vez do Apêndice A. Gostaria que isso ficasse no lado esquerdo do cabeçalho e a primeira página do apêndice não tivesse cabeçalho (assim como o capítulos).
Dificuldade do cabeçalho do apêndice:
Aqui está um MWE do meu documento até agora (desculpe, tem muitos comentários e a saída não é a mesma das imagens mostradas neste tópico).
\documentclass[12pt,a4paper]{report}
%----------------------------------------------------------------------------------------
% PACKAGES
%----------------------------------------------------------------------------------------
%% PAGE MARGINS
\usepackage[margin=1in]{geometry}
%% RANDOM LOREM IPSUM TEXT TO FILL
\usepackage{blindtext}
%% TOC BABEL
\usepackage[english]{babel}
%% HYPERLINKING
\usepackage[colorlinks=true]{hyperref}
\hypersetup{%
colorlinks,
linkcolor={red!50!black},
citecolor={blue!50!black},
urlcolor={blue!80!black}
}
%% HEADERS AND FOOTERS
\usepackage{fancyhdr}
%% HEADING TITLES (TITLE SECTIONS)
\usepackage{titlesec}
%% MAKES THE TOC WORK BETTER IMO (NOT SURE HOW)
\usepackage{tocloft}
%% INCLUDE PDF PAGES
\usepackage{pdfpages}
%----------------------------------------------------------------------------------------
% PAGE STYLE - HEADERS AND FOOTERS SETUP
%----------------------------------------------------------------------------------------
\pagestyle{fancy}
%% HEADER
\fancyhead[L]{\leftmark} % SECTION NAME-FIRST SECTION/PREVIOUS SECTION
\fancyhead[R]{\nouppercase{\rightmark}} % CHAPTER NAME
%--------------------------------------------------------------------------
%% FOOTER
\fancyfoot[C]{\small \thepage} % PAGE NUMBER
\fancyfoot[L]{\small ENEL895 \\ Version 1.0} % PAPER CODE AND VERSION
\fancyfoot[R]{\small \today} % TODAY'S DATE
\renewcommand{\footrulewidth}{1pt} % FOOTER RULE LINE
%--------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
% REDEFINING CHAPTER AND SECTION (LEFT AND RIGHT MARKS) TO BE THE % CHAPTER & SECTION NAMES AND NOT CAPITALISED.
%----------------------------------------------------------------------------------------
%% CHAPTER DEFINED AS RIGHT MARK (Chapter # - Chapter Name)
\renewcommand{\chaptermark}[1]{%
\markboth{}{\chaptername
\ \thechapter ~- #1}}
%% SECTION DEFINED AS LEFT MARK (# Section Name)
\renewcommand{\sectionmark}[1]{\markboth{\thesection\ #1}{}}
%----------------------------------------------------------------------------------------
% REDEFINE THE CHAPTER HEADING FORMAT AND VERTICAL SPACING
%----------------------------------------------------------------------------------------
%% SIZE AND FORMAT OF CHAPTER HEADING TITLE
\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
% ALTERS "BEFORE" SPACING (SECOND ARGUMENT) TO 0
\titlespacing*{\chapter}{0pt}{0pt}{20pt}
%----------------------------------------------------------------------------------------
% EDITING THE TOC TITLE AND DOTTED LINE SEGMENTS FOR CHAPTERS
%----------------------------------------------------------------------------------------
%% CHANGE TITLE TO "Table of Contents"
\addto\captionsenglish{% Replace "english" with the language you use
\renewcommand{\contentsname}%
{Table of Contents}%
}
%% ADD DOTTED LINES FOR CHAPTERS IN TOC
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % for chapters, if you really want!
%----------------------------------------------------------------------------------------
% CHANGE LINE SPACING TO 1.5
%----------------------------------------------------------------------------------------
\renewcommand{\baselinestretch}{1.5}
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
%----------------------------------------------------------------------------------------
% END OF PREAMBLE AND START OF DOCUMENT
%----------------------------------------------------------------------------------------
%--------------------------------------------------------------------------
%--------------------------------------------------------------------------
\begin{document}
%----------------------------------------------------------------------------------------
% PDF TITLE PAGE (NOT INCLUDED FOR MWE)
%----------------------------------------------------------------------------------------
%-----------------------------PDF PAGE---------------------------------
\pagenumbering{roman}
%----------------------------------------------------------------------------------------
% STATEMENT OF ORIGINALITY
%----------------------------------------------------------------------------------------
\section*{\LARGE\center{Statement of Originality\markboth{}{Statement of Originality}}}
\addcontentsline{toc}{chapter}{{Statement of Originality}}
\thispagestyle{fancy}
\newpage
%----------------------------------------------------------------------------------------
% ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------
\section*{\LARGE\center{Acknowledgements (optional)\markboth{}{Acknowledgements}}}
\addcontentsline{toc}{chapter}{{Acknowledgements}}
\thispagestyle{fancy}
\newpage
%----------------------------------------------------------------------------------------
% ABSTRACT
%----------------------------------------------------------------------------------------
\section*{\LARGE\center{Abstract\markboth{}{Abstract}}}
\addcontentsline{toc}{chapter}{{Abstract}}
\thispagestyle{fancy}
\newpage
%----------------------------------------------------------------------------------------
% ACRONYMS (OPTIONAL)
%----------------------------------------------------------------------------------------
\section*{\LARGE\center{Acronyms (optional)\markboth{}{Acronyms}}}
\addcontentsline{toc}{chapter}{{Acronyms}}
\thispagestyle{fancy}
\newpage
%----------------------------------------------------------------------------------------
% SYMBOLS (OPTIONAL)
%----------------------------------------------------------------------------------------
\section*{\LARGE\center{Symbols (optional)\markboth{}{Symbols}}}
\addcontentsline{toc}{chapter}{{Symbols}}
\thispagestyle{fancy}
\newpage
%----------------------------------------------------------------------------------------
% TABLE OF CONTENTS
%----------------------------------------------------------------------------------------
\begin{center}
\hypersetup{linkcolor=black} % Make Links Black
\vspace*{-40pt}
\tableofcontents\thispagestyle{fancy}\markboth{}{Table of Contents}
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\vspace*{-40pt}
\listoffigures\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Figures}
\newpage
\vspace*{-40pt}
\listoftables\thispagestyle{fancy}\markboth{}{}
\addcontentsline{toc}{chapter}{List of Tables}
\end{center}
\newpage
\pagenumbering{arabic}
%----------------------------------------------------------------------------------------
% MAIN TEXT (CHAPTERS)
%----------------------------------------------------------------------------------------
\chapter{Introduction}
\section{Introduction}\thispagestyle{fancy}
\Blindtext
\blindtext
\chapter{Literature Review}\thispagestyle{fancy}
\section{Background/Problem}
\blindtext
\section{Analysis..}
\Blindtext
\Blindtext
\chapter{Methodology}\thispagestyle{fancy}
\section{Procedure}
\blindtext\\
\blindtext \\
\blindtext\\
\blindtext
\section{Simulation?}
\blindtext\\
\blindtext \\
\blindtext
\chapter{Results and Discussion}\thispagestyle{fancy}
\section{Results Verification?}
\Blindtext
\chapter{Future Developments}\thispagestyle{fancy}
\section{Recommendations for Future Work}
\blindtext\\
\blindtext
\chapter{Conclusion}\thispagestyle{fancy}
\section{Conclusion}
\blindtext
%----------------------------------------------------------------------------------------
% APPENDIX
%----------------------------------------------------------------------------------------
\begin{appendix}
\chapter{Example 1}\thispagestyle{fancy}
\section{Testing}
\Blindtext
\chapter{Example 2}\thispagestyle{fancy}
\section{Extra}
\blindtext
\end{appendix}
%----------------------------------------------------------------------------------------
% BIBLIOGRAPHY/REFERENCES
%----------------------------------------------------------------------------------------
%-------------------------------REFS-----------------------------------
\end{document}
Desculpe, este tópico é tão longo, pensei em tentar explicar detalhadamente meus problemas e o resultado desejado. Atualmente estou usando o fancyhdr
pacote, mas se você acredita que devo usar o equivalente ao KOMA Script, fique à vontade para deixar um comentário sobre como devo usá-lo (não usei o KOMA Script antes).
Obrigado.
Responder1
Se você estiver disposto a usar a memoir
classe (um superconjunto das classes book
e report
), poderá obter os cabeçalhos/rodapés desejados. Eu sei que parece complicado, mas memoir
permite definir muitos estilos de página e onde eles serão usados.
Parece-me que você deseja vários estilos de página diferentes; para o ToC (e presumivelmente o LoT e LoF também), talvez para a página de título, para páginas de título de capítulo, para páginas de documentos gerais, talvez para um índice ou bibliografia.
O MWE a seguir fornece seus estilos de página para ToC e LoT, páginas de título de capítulo (incluindo apêndices) e páginas comuns em geral.
% headersprob.tex SE 562212
\documentclass{memoir}
\usepackage{lipsum}
\usepackage{comment}
% macro for details of the footer style
\newcommand{\enelf}[1]{%
\makeevenfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makeoddfoot{#1}{\small \parbox[t]{1in}{ENEL895 \\ Version 1.0}}{\small \thepage}{\small \today}
\makefootrule{#1}{\textwidth}{1pt}{5pt}
}
\makepagestyle{ENELfoot}
\enelf{ENELfoot}
% pagestle for the ToC
\makepagestyle{ENELtoc}
\makeevenhead{ENELtoc}{}{}{Table of Contents}
\makeoddhead{ENELtoc}{}{}{Table of Contents}
\makeheadrule{ENELtoc}{\textwidth}{1pt}
\enelf{ENELtoc}
% pagestyle of the LoT
\makepagestyle{ENELlot}
\makeevenhead{ENELlot}{}{}{List of Tables}
\makeoddhead{ENELlot}{}{}{List of Tables}
\makeheadrule{ENELlot}{\textwidth}{1pt}
\enelf{ENELlot}
% pagestyle for chapter pages
\makepagestyle{chapter}
\enelf{chapter}
% don't uppercase chapter and section titles in headers
% (regular definition uses \MakeUppercase for titles)
\makeatletter
\renewcommand*{\chaptermark}[1]{%
\markboth{\ifnum\c@secnumdepth > \m@ne
\if@mainmatter
\@chapapp\
\thechapter \ %
\fi
\fi
#1}{}}
\renewcommand*{\sectionmark}[1]{%
\markright{\ifnum\c@secnumdepth > \z@
\thesection \ %
\fi
#1}}
\makeatother
% The page style for the bulk of the document
\makepagestyle{ENELmain}
\makeevenhead{ENELmain}{\leftmark}{}{\rightmark}
\makeoddhead{ENELmain}{\leftmark}{}{\rightmark}
\enelf{ENELmain}
\begin{document}
\pagestyle{ENELfoot}
\frontmatter
\pagestyle{ENELtoc}
\copypagestyle{chapter}{ENELtoc} % the first page of the ToC uses the chapter pagestyle
\tableofcontents
\clearpage
\pagestyle{ENELlot}
\copypagestyle{chapter}{ENELlot} % the first page of the LoT uses the chapter page style
\listoftables
\mainmatter
% set the general page style
\pagestyle{ENELmain}
% first page of a chapter uses the chapter page style, so set it to be just the footer
\copypagestyle{chapter}{ENELfoot}
\chapter{One}
\lipsum
\section{A section}
\begin{table}
\centering
TABULATION
\caption{A table}
\end{table}
\lipsum
\addtocontents{toc}{\newpage} % make sure the ToC is more that one page
\section{Another section}
\lipsum
\appendix
\chapter{App}
\lipsum
\section{In appendix}
\lipsum
\end{document}
Leia a documentação ( > texdoc memoir
Capítulo 7) para obter mais informações.
Responder2
Como a documentação do pacote do fancyhdr aponta os \chapter
problemas do comando \thispagestyle{plain}
.
Eu acredito \tableofcontents
que isso também. Portanto, pode ser necessária
uma redefinição do estilo de página . Você pode fazer isso adicionando ao preâmbulo, que define o estilo de página como estilo de página, exceto ter um cabeçalho vazio. Isso resulta em não ter cabeçalho, mas rodapé nas páginas onde um novo capítulo é introduzido. Não se esqueça de remover sempre que criar um novo capítulo.plain
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrule}{}}
plain
fancy
\thispagestyle{fancy}
Quanto ao cabeçalho não ser exibido em todas as páginas, o problema parece ser a definição \captionmark
e \sectionmark
.
O que descobri que parece funcionar é remover essas redefinições e adicionar \nouppercase
a definição de ambos os cabeçalhos, levando a
\fancyhead[L]{\nouppercase\leftmark} % SECTION NAME-FIRST SECTION/PREVIOUS SECTION
\fancyhead[R]{\nouppercase\rightmark} % CHAPTER NAME