# Section name appearing twice

Why the section name is showing twice?

\documentclass[12pt]{report}
\usepackage{enumitem}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}{}
\renewcommand{\chaptermark}[1]{\markboth{}{}}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}
\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}
\begin{document}
\pagenumbering{arabic}
\chapter{Introduction}
Inro
\section{Objective}
The \section{Thesis Outline}
\end{document}

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – egreg Jul 4 '16 at 14:54
• I have more than 1000 line code. Actually I am writing a thesis for my project – Shraddha Vardikar Jul 4 '16 at 15:09
• We can't guess, sorry. Try minimizing your code until you get a small example reproducing the issue. – egreg Jul 4 '16 at 15:09
• @ShraddhaVardikar -- you can always edit your own question. (two people have worked on editing the code from the comment into the question, but it would not have needed to be re-flowed if you had inserted it directly.) – barbara beeton Jul 4 '16 at 15:39
• The \renewcommand{\sectionmark}{} is wrong! – user31729 Jul 4 '16 at 15:39

## 2 Answers

\sectionmark is defined in the standard classes (such as report.cls) to have one argument.

Omitting it, the \section code calls \sectionmark{foo} this way:

\sectionmark%    does nothing if being defined as \renewcommand{\sectionmark}{}
foo


i.e. the orphaned argument foo appears in the input stream, i.e. it is typeset (in most cases, in rare cases it would be another macro that is executed)

\documentclass[12pt]{report}

\usepackage{enumitem}
\usepackage{fancyhdr}
\pagestyle{fancy}

\makeatletter
\renewcommand{\sectionmark}[1]{}%
% or
%\let\sectionmark\@gobble%
\makeatother
\renewcommand{\chaptermark}[1]{\markboth{}{}}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}

\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}

\begin{document}
\pagenumbering{arabic}
\chapter{Introduction} Intro
\section{Objective}
The \section{Thesis Outline}
\end{document}


• apologies for treading on your toes editing the question. – barbara beeton Jul 4 '16 at 15:44
• @barbarabeeton: No worries – user31729 Jul 4 '16 at 15:45

The redefinition of \sectionmark is wrong. However, since you seem to be redefining \sectionmark and \chaptermark just to get rid of headers, there's a much simpler solution: clearing all fields before redefining them.

I added also the code for using the same style also in chapter starting pages (but omitting the top rule).

\documentclass[12pt]{report}

\usepackage{enumitem}
\usepackage{fancyhdr}

\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\headrulewidth}{0.5pt}
\fancyhf{} % clear all fields
\fancyfoot[L]{\textit{NITK Surathkal}}
\fancyfoot[R]{\textit{Electrical Dept.}}
\fancyfoot[C]{\textit{\thepage}}

% add the following if you want a uniform style also
% for the chapter starting pages
\fancypagestyle{plain}
\renewcommand{\footrulewidth}{0.5pt}%
\renewcommand{\headrulewidth}{0pt}% no rule at the top
\fancyhf{}% clear all fields
\fancyfoot[L]{\textit{NITK Surathkal}}%
\fancyfoot[R]{\textit{Electrical Dept.}}%
\fancyfoot[C]{\textit{\thepage}}%
}

\begin{document}

\pagenumbering{arabic}
\chapter{Introduction}
Intro

\section{Objective}

\section{Thesis Outline}

\end{document}

• Thank you so much for your help! The h/f addition code to chapter starting pages is much appreciated :) – Shraddha Vardikar Jul 4 '16 at 21:52