0

I am creating my thesis using LaTeX where I used fancyhdr for defining my header and footer globally. What I am trying to attain are:

  1. Print shorter version of my current Chapter name as header on both sides of pages with rule (line).
  2. Print shorter version of my current Section name as footer on both sides of pages with rule (line).
  3. Chapter and Section title should be in full with in text space.
  4. Table of content should show the full version of my Chapter and Section names.

The problem I am facing is my table of contents shows the shortened version of Chapter and Section names where I want the full version.

MWE as follows:

\documentclass[a4paper,11pt]{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\fancyhead[L]{\textsl{\leftmark}}
\fancyfoot[L]{\textsl{\rightmark}}
\fancyfoot[R]{\thepage}
\renewcommand{\footrulewidth}{0.4pt}
\usepackage{lipsum}
\begin{document}
\tableofcontents
\chapter[headchap]{Heading of this chapter}
\section[Intro]{Introduction to the topic and scope of this work}
\lipsum{1-5}
\end{document}

Chapter and Section names in text space is working Header workingFooter working TOC not working as required in point (4) above

How to attain the four requirements mentioned above (preferably not using any extra packages)?

2

One way is to use the titlesec package with the toctitles option. For example:

\documentclass{article}
\usepackage[toctitles]{titlesec}
\usepackage{lipsum}
\pagestyle{headings}
\begin{document}
\tableofcontents
\section[L 1]{Lipsum 1}
\lipsum
\section[L 2]{Lipsum 2}
\lipsum
\section[L 3]{Lipsum 3}
\lipsum
\end{document}

Unfortunately, it doesn't affect chapters. So for the chapter you can use the following (now I'm adding code to your MWE):

\documentclass[a4paper,11pt]{book}
\usepackage[toctitles]{titlesec}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\fancyhead[L]{\textsl{\leftmark}}
\fancyfoot[L]{\textsl{\rightmark}}
\fancyfoot[R]{\thepage}
\renewcommand{\footrulewidth}{0.4pt}
\usepackage{lipsum}

\begin{document}
\tableofcontents
\chapter{Heading of this chapter}
\markboth{\MakeUppercase{\chaptername\ \thechapter. Headchap}}{\MakeUppercase{\chaptername\ \thechapter. Headchap}}
\section[Intro]{Introduction to the topic and scope of this work}
\lipsum{1-5}
\end{document} 

Again, toctitles is used for the sections, and a line of code is added after the chapter header. It mimics the standard book class behavior (uppercase word CHAPTER, then its number and then the short version of the header).

  • I tried this example it is working. Now the sections names in footer as well as in table of contents are as I wanted. But table of contents are still showing short version of chapter names. How to do the same thing you mentioned above with Chapter names ? – Nebuchedneiser Jul 5 at 8:32
  • Unfortunately, toctitles doesn't work with chapters. I'll add something in line with Barbara's answer to overcome that. – Sergei Golovan Jul 5 at 10:09
2

Without any packages, you can set "marks" to specify the content of running heads.

If you want the same header on both left and right pages:

\section{full section header}
\markboth{short header text}{short header text}

If you want this header on only the righthand pages:

\section{full section header}
\markright{short header text}
  • Editing in the question. Think I should have done this in the first place to help others. – Nebuchedneiser Jul 5 at 8:19
1

You did not mentioned the class used in your document.

With a KOMA-Script class you can use option headings=optiontohead:

\documentclass[headings=optiontohead]{scrbook}
\usepackage{lipsum}
\pagestyle{headings}
\begin{document}
\tableofcontents
\part[P 1]{Part 1}
\chapter[C 1]{Chatper 1}
\lipsum
\section[S 1]{Section 1}
\lipsum
\section[S 2]{Section 2}
\lipsum
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.