Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

\lhead{\leftmark}
\chead{}
\rhead{\rightmark}
\cfoot{\footnotesize\selectfont\bfseries\thepage}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\setlength{\headheight}{8pt}

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

\begin{document}
\lipsum[1]
  \pagenumbering{roman}
  \setcounter{page}{2}
\lipsum[1]
  \rhead{\footnotesize{\thesection{ } \leftmark}}
  \pagenumbering{arabic}
  \setcounter{page}{1}
\section{First Section}
\lipsum[2-5]
\section{Second Section}
\lipsum[2-8]
\end{document}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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}{%
    \fancyhead{}
    \renewcommand{\headrulewidth}{1pt}
}

and then start your sections by declaring

\section{Second Section}\thispagestyle{FooBar}

This will give you

enter image description here

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).

share|improve this answer
    
it was the FooBar solution what I was looking for. Thank you very much! –  Kaiser Schwarcz Jul 3 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{}
\fancyhead[L]{\leftmark}
\fancyfoot[C]{\footnotesize\bfseries\thepage}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

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

\fancypagestyle{section}{%
  \fancyhf{}%
  \fancyfoot[C]{\footnotesize\bfseries\thepage}
  \renewcommand{\headrulewidth}{0.4pt}%
  \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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.