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}
Share:
1,930

Related videos on Youtube

enthu
Author by

enthu

Updated on November 12, 2020

Comments

  • enthu
    enthu almost 3 years

    I want to have chapter and subsection in the headings of my document. but the numbering should not exist.

    • Werner
      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
    enthu over 9 years
    thanks. 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
    izabera over 9 years
    @Parsa Updated my answer. Is it clear enough?
  • enthu
    enthu over 9 years
    does it appear unnumbered in the page headings? + what is the difference between \mychapter and \include{filename} + what is left and right mark?
  • izabera
    izabera over 9 years
    Section 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. The fancyhdr package may help to customize your header and footer. About \include{filename} check this answer for a good explanation.
  • enthu
    enthu over 9 years
    thanks, I do not know how to thank you. Let me check it and I will check mark your answer.