
O código atual do meu documento látex é este:
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\nouppercase{\textit \leftmark}}
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\thispagestyle{plain}
\newpage
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
Quero remover o "Capítulo 1". palavra-chave do meu cabeçalho "Capítulo 1. Um" e quero assim: "1-One". Como fazer isso?
Responder1
Você pode redefinir \chaptermark
como em
\renewcommand\chaptermark[1]{\markboth{\thechapter\,--\,#1}{}}
Um exemplo completo:
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\nouppercase{\textit{\leftmark}}}
\renewcommand\chaptermark[1]{\markboth{\thechapter\,--\,#1}{}}
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\thispagestyle{plain}
\newpage
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
Responder2
Como alternativa fancyhdr
você pode usarscrlayer-scrpage
:
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage[pagestyleset=KOMA-Script,headsepline,automark]{scrlayer-scrpage}
\setkomafont{pagehead}{\itshape}% use italic instead of slanted page header
\renewcommand*{\chaptermarkformat}{\thechapter--}% Use "1–" instead of "Chapter 1 " in the chapter mark
\begin{document}
\pagenumbering{roman}
\cleardoublepage
\addcontentsline{toc}{chapter}{Table of Contents}% Has to be at the begin of
% the first ToC page (before \tableofcontents)
\tableofcontents
\cleardoublepage% if twoside next odd page
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
Nota: também removi \thispagestyle{plain}
comandos estranhos e movi o \addcontentsline
comando. No seu exemplo, adicionaria a última página do índice ao índice, o que não faria sentido.
Como alternativa, você pode usar o pacotetocbibind
.
No entanto, eu recomendaria não adicionar uma entrada para o índice ao índice. Principalmente isso não faz nenhum sentido.
Responder3
Uma possibilidade simples é carregar titleps
o , que vem junto titlesec
, mas pode ser usado de forma independente. Não brinque com marcas (a menos que você queira…). Apenas c \chaptertitle
. \sectiontitle
).
\documentclass[12pt,notitlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{mypagestyle}{%
\headrule
\sethead{}{\textit{\thechapter.\,–\,\chaptertitle}}{}
\setfoot{}{\thepage}{}
}%
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\pagestyle{mypagestyle}
\pagenumbering{arabic}
\chapter{One}
\lipsum
\end{document}