
Estou escrevendo meu relatório de tese e quero manter os nomes das seções no cabeçalho das páginas. No momento, o número da página está no centro do rodapé e quero mantê-lo da mesma forma. Eu tentei usar o fancyhdr para manter o nome da seção, mas o problema é que ele também mostrará o cabeçalho do conteúdo e a lista de figuras, que estão em \frontmatter. Quaisquer sugestões seriam úteis.
%\documentclass[12pt,a4paper]{article}
\documentclass[12pt,a4paper]{article}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
%function definition for starting intro from first section.
\def\frontmatter{%
\pagenumbering{roman}
\setcounter{page}{1}
\renewcommand{\thesection}{\Roman{section}}
}%
\def\mainmatter{%
\pagenumbering{arabic}
\setcounter{page}{1}
\setcounter{section}{0}
\renewcommand{\thesection}{\arabic{section}}
}%
\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage{makecell}
\usepackage{graphicx}
Responder1
Você pode usar fancyhdr
e definir seus próprios estilos de página e usar \pagestyle{...}
no final das definições para \mainmatter
e \frontmatter
.
Configuração de estilos de página
% Page Layout
\setlength{\headheight}{15pt} % otherwise fancyhdr gives warning
\fancyhf{}
\fancypagestyle{frontmatter}{
\fancyhf{} % clearing headers and footers
\fancyfoot[C]{\thepage} % page number centered in the footer
\renewcommand{\headrulewidth}{0pt} % Create an invisible header ruler line
}
\fancypagestyle{mainmatter}{
\fancyhf{}
\fancyhead[C]{\leftmark} % \leftmark gives current section with its number you may want to use \nouppercase
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.3pt} % Create an header ruler line
}
Responder2
Com base nas suas necessidades, isso pode ser alcançado sem o fancyhdr
pacote. Aqui está um código de exemplo:
\documentclass[12pt,a4paper]{article}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pagestyle `headings` setting %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\def\ps@headings{%
\def\@oddfoot{\hfil\thepage\hfil}
\def\@oddhead{\hfil\slshape\rightmark\hfil}%
\def\@evenhead{\hfil\slshape\rightmark\hfil}%
\let\@mkboth\markboth
\def\sectionmark##1{%
\markright {%
\ifnum \c@secnumdepth >\m@ne
\thesection\quad
\fi
##1}}}
\makeatother
%%%%%%%%%%%%%%%%%%
% other packages %
%%%%%%%%%%%%%%%%%%
\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage{makecell}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{mwe}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%
% title page %
%%%%%%%%%%%%%%
\thispagestyle{empty}
\null\vfil
\begin{center}
\textbf{My Title}
\vskip 3em
\textbf{My Name}
\end{center}
\vfil\null
\clearpage
%%%%%%%%%%%%%%%
% frontmatter %
%%%%%%%%%%%%%%%
\pagenumbering{roman}
\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage
%%%%%%%%%%%%%%
% mainmatter %
%%%%%%%%%%%%%%
\pagenumbering{arabic}
\pagestyle{headings}
\section{Introduction}
\lipsum[1]
\clearpage
\section{Analysis}
\lipsum[2]
\begin{figure}[ht]
\centering
\includegraphics{example-image-a}
\caption{figure 1}
\label{fig:my_label}
\end{figure}
\clearpage
\section{Results}
\begin{table}[ht]
\centering
\begin{tabular}{c|c}
1&2 \\
3&4
\end{tabular}
\caption{table 1}
\label{tab:my_label}
\end{table}
\lipsum[3]
\end{document}