Chapter/Section title in header without numbering
1,930
Maybe you can redefine your chapters and sections?
\documentclass{book}
\usepackage{lipsum}
\newcommand\mychapter[1]{\chapter*{#1}%
\addcontentsline{toc}{chapter}{\protect\numberline{}#1}%
\def\rightmark{#1}}
\newcommand\mysection[1]{\section*{#1}%
\addcontentsline{toc}{section}{\protect\numberline{}#1}%
\def\leftmark{#1}}
\begin{document}
\tableofcontents
\mychapter{First chapter}
\mysection{First section}
\lipsum[1-10]
\mysection{Second section}
\lipsum[1-10]
\mychapter{Second chapter}
\lipsum[1-10]
\end{document}
When you write \mychapter{Chapter title}
, latex will:
- create an unnumbered chapter with that title:
\chapter*{#1}
add it to the table of contents:
\addcontentsline{toc}{chapter}{\protect\numberline{}#1}
(unnumbered things usually don't show up in the toc)
- set the correct title in the page headings:
\def\rightmark{#1}
Related videos on Youtube
Author by
enthu
Updated on November 12, 2020Comments
-
enthu almost 3 years
I want to have chapter and subsection in the headings of my document. but the numbering should not exist.
-
Werner over 9 years"Just to mention"... it would be great if you could provide us with a minimal working example (MWE), since sectional units and headings are very dependent on the document class and packages you are using (or limited to use).
-
-
enthu over 9 yearsthanks. could you please a little talk about those new commands? I am very new to LaTeX and I am so sorry that my questions seem so simple to the community.
-
izabera over 9 years@Parsa Updated my answer. Is it clear enough?
-
enthu over 9 yearsdoes it appear unnumbered in the page headings? + what is the difference between \mychapter and \include{filename} + what is left and right mark?
-
izabera over 9 yearsSection and chapters will appear unnumbered in the page headings and the table of contents.
\rightmark
controls the right page header,\leftmark
the left page header. Thefancyhdr
package may help to customize your header and footer. About\include{filename}
check this answer for a good explanation. -
enthu over 9 yearsthanks, I do not know how to thank you. Let me check it and I will check mark your answer.