1

my problem I try to have the section names in the header. Some sections are not numbered, however do I want them as well in my header.

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{}
\fancyhf{}
\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}
\fancyfoot[LE,RO]{\thepage}
\setlength{\headsep}{.5cm}

This is the codes I use for my headers and footers.

\section*{List of Symbols and Abbreviations}

The list of symbols doesn't have to be numbered, so I put an asterisk after \section. Is there a way to have "List of Symbols and Abbreviations" in the header?

This is the code to copy+past and try it out by yourself..

\documentclass[10pt, a4paper,twoside]{scrartcl}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancypagestyle{plain}{}
\fancyhf{}

\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}

\setlength{\headsep}{.5cm}


\begin{document}

\section*{Abstract}

\newpage

\tableofcontents
\newpage

\listoffigures
\newpage

\section*{List of Symbols}
\newpage

\section{Introduction}
\newpage                        
 
\section{Basics}
\newpage

\section*{appenix}
\end{document}

as you can see the section abstract, list of symbols and appenix is not displayed in the header, whereas the section introduction is displyed

2
  • Welcome to TeX SX! Could you please post a small, yet complete, code?
    – Bernard
    Commented Oct 18, 2020 at 11:55
  • From the two answers posted it's clear that we've understood different things about what you want in the table of contents. I'm assuming, since the list of figures is in the TOC, that you want unnumbered sections in the TOC. Can you please clarify?
    – Alan Munn
    Commented Oct 18, 2020 at 18:06

2 Answers 2

0

Try this code. I understand that you use the starred commands to avoid having those section appearing in the TOC.

\documentclass[10pt, a4paper,twoside]{scrartcl}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancypagestyle{plain}{}
\fancyhf{}

\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}

\setlength{\headsep}{.5cm}


\begin{document}

\section*{Abstract \protect\markboth{Abstract}{Abstract} }

\newpage

\tableofcontents
\newpage

\listoffigures
\newpage

\section*{List of Symbols\protect\markboth{List of Symbols}{List of Symbols}}
\newpage

\section{Introduction}
\newpage                        
 
\section{Basics}
\newpage

\section*{Appendix \protect\markboth{Appendix}{Appendix}}
\end{document}

output

3
  • Thank you! that worked Commented Oct 19, 2020 at 5:14
  • @caarloXY I know you say that this worked, but with this solution your List of Figures appears in the table of contents, but the List of Symbols doesn't. Is this really what you want? It's certainly not very consistent. (This isn't meant as a criticism of Simon's answer, as they can easily modify it to work.)
    – Alan Munn
    Commented Oct 19, 2020 at 14:06
  • I checked my document again, it doesn't appear. anyways, Thanks for the hint. Commented Oct 19, 2020 at 16:17
0

A simple way to deal with this sort of thing is to simply change the \secnumdepth counter in the different parts of the document and not use \section* at all and instead just use \section. Then the correct elements will appear both in the TOC and in the headers without any manual intervention other than changing the sectioning depth. For the appendix I've used the \appendix command that changes the section numbering there too.

\documentclass[10pt, a4paper,twoside]{scrartcl}

\usepackage{fancyhdr}
\pagestyle{fancy}

\fancypagestyle{plain}{}
\fancyhf{}

\fancyhead[RE,LO]{\rmfamily \small \nouppercase \leftmark}

\setlength{\headsep}{.5cm}
\begin{document}
\setcounter{secnumdepth}{0} % turn of numbering of sections in the frontmatter
\section{Abstract}
\newpage

\tableofcontents
\newpage

\listoffigures
\newpage

\section{List of Symbols}
\newpage
\setcounter{secnumdepth}{3} % turn on numbering in the main matter
\section{Introduction}
\newpage                        
 
\section{Basics}
\newpage
\appendix
\setcounter{secnumdepth}{0} % turn it off again in the back matter
\section{Appendix}
\end{document}

abstract header list of symbols header

4
  • good idea, however I have set my \secnumberdepth already at 3. because I want my section to be numbered Commented Oct 19, 2020 at 5:15
  • Try the whole code
    – Alan Munn
    Commented Oct 19, 2020 at 5:16
  • Ouh, I see now. thanks ! Commented Oct 19, 2020 at 5:17
  • And this puts everything in the TOC which I think you want?
    – Alan Munn
    Commented Oct 19, 2020 at 5:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .