# Remove section number = 0 in the header

I have section numbers and section titles in my header. I want to remove the section number before the table of contents. While the section number = 0. And keep it in the rest of my document.

Does anyone have a good suggestion for this problem?

I also wonder if it's possible to write the subsection number in the header?

My main-file:

\documentclass{article}

\input{packages.tex}

\begin{document}

\large
\pagenumbering{gobble}
\setcounter{secnumdepth}{0}

Preface + abstract ++

\tableofcontents
\pagenumbering{arabic}
\setcounter{secnumdepth}{5}

Text..........

\setcounter{table}{0}

Apendix....

\end{document}


My packages-file:

\usepackage[utf8]{inputenc}
\usepackage[usenames, dvipsnames]{color}
\usepackage[nynorsk]{babel}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhf{}

\lhead{\fancyplain{}{\rightmark }} % 1. sectionname, 1.1 subsection name etc
\cfoot{\fancyplain{}{\thepage}}

• I am not sure if this is what you want, but try: \renewcommand\thetable{\arabic{table}} in your preamble Jun 16 '17 at 12:29
• I did not understood before... I thought you want to remove \thesection from the \thetable ... looking for new answer Jun 16 '17 at 12:38
• Welcome to TeX - LaTeX! Can you reduce your code the parts are relevant to the question. See minimal working example (MWE) for help as to make a usable subset of your code. Jun 16 '17 at 12:43
• In my preface (before table of contens) I have no section numbering (or page numbering). I have header with section number, section title and document title. The problem is that I don't want the section number to show up, while it's equal to zero. (In the preface.) Jun 16 '17 at 13:01
• In my header '0 Preface' is left aligned and the title 'Master thesis' are right aligned. Jun 16 '17 at 13:01

In article, \sectionmark should do \markboth.

\documentclass[11pt]{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[nynorsk]{babel}

\usepackage[usenames,dvipsnames]{color}
\usepackage{fancyhdr}

\usepackage{blindtext} % just for the example

\fancyhf{}
\fancyhead[R]{Title''}
\fancyhead[L]{\nouppercase{\leftmark}} % 1. sectionname, 1.1 subsection name etc
\fancyfoot[C]{\thepage}

\fancypagestyle{frontmatter}{%
\fancyhf{}%
\fancyhead[R]{Title''}%
}

\renewcommand{\sectionmark}[1]{%
\markboth{\ifnum\value{section}=0 \else\thesection\ \fi #1}{}%
}
\renewcommand{\subsectionmark}[1]{}

\begin{document}

\pagestyle{frontmatter}
\setcounter{secnumdepth}{0}

\section{Preface}
\blindtext
\blindtext
\blindtext
\blindtext

\section{Abstract}
\blindtext

\clearpage
\tableofcontents

\clearpage
\pagestyle{fancy}
\pagenumbering{arabic}
\setcounter{secnumdepth}{5}

\blinddocument

\setcounter{table}{0}

Appendix....

\end{document}


Avoid \pagenumbering{gobble}; if you need to use hyperref, add \pagenumbering{Alph} after \pagestyle{frontmatter}.

• Impressive screenshot :) Jun 16 '17 at 13:35