2

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{}      

    \rhead{\fancyplain{}{"Title"}} 
    \lhead{\fancyplain{}{\rightmark }} % 1. sectionname, 1.1 subsection name etc
    \cfoot{\fancyplain{}{\thepage}}
5
  • I am not sure if this is what you want, but try: \renewcommand\thetable{\arabic{table}} in your preamble
    – koleygr
    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
    – koleygr
    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.)
    – Anders
    Jun 16 '17 at 13:01
  • In my header '0 Preface' is left aligned and the title 'Master thesis' are right aligned.
    – Anders
    Jun 16 '17 at 13:01
4

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''}%
  \fancyhead[L]{\nouppercase{\leftmark}}%
}

\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}.

enter image description here

1

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.