7

I've copied a code to have a header that prints the section name on the left and my name on the right:

\usepackage{fancyhdr}

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

\fancyhf{}

\rhead{\fancyplain{}{MyName}}
\lhead{\fancyplain{}{\rightmark }} 
\cfoot{\fancyplain{}{\thepage}}

The problem is that it prints the section number as well, which I don't want. I've experimented with removing the 1's in the code but that doesn't work.

3
  • Please make your code compilable, starting with \documentclass{...} and ending with \end{document}.
    – jub0bs
    Apr 29, 2013 at 11:16
  • 3
    Try substituting \renewcommand{\sectionmark}[1]{\markright{#1}} for \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} in your code.
    – jub0bs
    Apr 29, 2013 at 11:20
  • Thanks Jubobs, that is indeed the solution. I don' tknow how to mark it as the answer
    – Blackstone
    Apr 29, 2013 at 11:24

1 Answer 1

11

\thesection prints the section number (preceded by the chapter number, if you use a class that can include chapters, such as book). Get rid of it and of the following control space (\) and you obtain the desired output:

enter image description here

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{lipsum}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{#1}}
\fancyhf{}
\rhead{\fancyplain{}{MyName}}
\lhead{\fancyplain{}{\rightmark }} 
\cfoot{\fancyplain{}{\thepage}}

\begin{document}
\chapter{Foo}
\section{bar}
\lipsum
\end{document}

You must log in to answer this question.

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