# How to hide header only in first page of each section with fancyhdr?

I want the header to be empty in the page were section begins and showed in the other pages. How can I do that?

\documentclass[12pt, titlepage, onecolumn, a4paper]{article}

\usepackage{lipsum}    %% for dummy text

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} % set the \leftmark
\fancyhf{}

\cfoot{\footnotesize\selectfont\bfseries\thepage}

\renewcommand{\footrulewidth}{0.4pt}

\renewcommand{\thefigure}{\thesection.\arabic{figure}}
\renewcommand{\thetable}{\thesection.\arabic{table}}

\begin{document}
\lipsum[1]
\pagenumbering{roman}
\setcounter{page}{2}
\lipsum[1]
\pagenumbering{arabic}
\setcounter{page}{1}
\section{First Section}
\lipsum[2-5]
\section{Second Section}
\lipsum[2-8]
\end{document}

-

I'm not sure what do you mean by empty but if you are looking for the normal layout without the text of the header you can add this pagestyle to your preamble:

\fancypagestyle{FooBar}{%
}


and then start your sections by declaring

\section{Second Section}\thispagestyle{FooBar}


This will give you

If you literally need an empty layout, you can use \thispagestyle{empty} as it is already defined by the package (an other predefined style is plain).

-
it was the FooBar solution what I was looking for. Thank you very much! –  Kaiser Schwarcz Jul 3 '14 at 14:07

You can make the choice automatic, by adding some code to \section

\documentclass[12pt, titlepage, onecolumn, a4paper]{article}
\usepackage{fancyhdr}
\usepackage{chngcntr}
\usepackage{xparse}

\usepackage{lipsum}    %% for dummy text

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} % set the \leftmark
\fancyhf{}
\fancyfoot[C]{\footnotesize\bfseries\thepage}

\renewcommand{\footrulewidth}{0.4pt}

\setlength{\headheight}{14.5pt} % <-------- 8pt is too small!

\fancypagestyle{section}{%
\fancyhf{}%
\fancyfoot[C]{\footnotesize\bfseries\thepage}
\renewcommand{\footrulewidth}{0.4pt}%
}

\counterwithin{figure}{section}
\counterwithin{table}{section}

% the starting page of a section will not have a header
\let\originalsection\section
\RenewDocumentCommand{\section}{som}{%
\IfBooleanTF{#1}
{\originalsection*{#3}}
{\IfNoValueTF{#2}
{\originalsection{#3}}
{\originalsection[#2]{#3}}%
}%
\thispagestyle{section}%
}

\begin{document}
\lipsum[1]
\lipsum[1]
\section{First Section}
\lipsum[2-5]
\section{Second Section}
\lipsum[2-8]
\end{document}


I added also the correct size for \headheight (unless you use a smaller font 14.5pt is necessary). Also I removed the setting of \rightmark, add it if really wanted, but then you probably have to redefine \subsectionmark.

Also I defined the counters for tables and figures using chngcntr and \counterwithin; this way the counters will be reset at each section.

-

It can also be achieved if you define the \fancypagestyle, as Pouya did:

\fancypagestyle{FooBar}{%
}


and somewhere in the preamble (before \begin{document}) state:

\let \OldSection \section
\renewcommand{\section}[1]{\OldSection{#1} \thispagestyle{FooBar}}


:: Update ::

In my case, sometimes, I want to open a section on a new page, using memoir. So, I use the following tex:

\documentclass[12pt,twoside,a4paper]{memoir}

\usepackage{lipsum}    %% for dummy text

\let\footruleskip\undefined
\usepackage{fancyhdr}

% Apply section style
\let \OldSection \section
\renewcommand{\section}[1]{\OldSection{#1} \thispagestyle{plainsec}}

% Define your page styles
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter\ - #1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection\ - #1}}
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{  %chapter openning
\fancyhf{}
}
\fancypagestyle{plainsec}{  %section openning
\fancyhf{}
}

\begin{document}
\chapter{First Chapter}
\lipsum[1]
\section{A Section after some text}
\lipsum[2-5]
\subsection{A Sub-section}
\lipsum[2-5]

\cleardoublepage
\section{A Section at a new page}
\lipsum[2-8]
\end{document}

-
Please elaborate on this and show a screen shot, for example –  Christian Hupfer Dec 30 '14 at 13:10
I add an example above. If you want, you can define a specific section command, whenever you need a section opening like a chapter usually does. –  tasilva Dec 31 '14 at 0:22