[Tex/LaTex] How to print the section name without the section number in a fancyhdr header

fancyhdrheader-footer

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.

Best Answer

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