6

I have a problem with headers and footers. When im making header, it goes on the top of my text. Maybe someone can help to fix it.

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{fancyhdr}
\titleformat{\section}[block]{\Large\bfseries\filcenter}{\thesection}{1em}{}
\titleformat{\subsection}[hang]{\bfseries\filcenter}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[hang]{\bfseries\filcenter}{\thesubsubsection}{1em}{}
\renewcommand{\thesection}{\arabic{section}}\pagestyle{fancy} 
\fancyfoot{}
\fancyfoot[LE,LO]{MY TEXT}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}

and this is result, which i get: enter image description here

I hope it is enough info to fix it. Thanks!

  • 1
    It's not enough; please make a minimal working example (MWE) – egreg Aug 22 '13 at 13:37
  • i dont know if i understood correctly what is MWE, but i tried to put more info in my code. I dont know if thats right –  Aug 22 '13 at 13:45
  • Click the hyper link in @egreg's comment. – dustin Aug 22 '13 at 13:47
  • 1
    Looking at your output, I would say that you use more than fancyhdr to produce your document; in particular, the layout of your sections/subsections in not standard. Moreover, still based on the result of your code, I would say that you should play with the different lengths of your page (you can find the different lengths and what are their use in the fancyhdr documentation, page 3), something is probably wrong regarding the \textheight, the \topmargin or the \headheight. – MBR Aug 22 '13 at 14:40
  • I had this issue because I included \usepackage{fullpage} – Merlijn Sebrechts Dec 14 '18 at 16:20

1 Answers1

2

You should set the page style to fancy and clean the fancy header with following command:

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt} % no line in header area
\fancyhead{}
\chead{your header in center} %\lhead and \rhead also available
sajjadG
  • 618
  • 1
  • 8
  • 15
  • 1
    There is already a \pagestyle{fancy} hidden in is bit of code, and I strongly suspect that what you say won't help since it is more a problem related to the size of the elements of the page than anything else. – MBR Aug 23 '13 at 07:51
  • @MBR I had this problem and solve it by this code. I updated with my working copy. place this before \begin{document} – sajjadG Aug 23 '13 at 07:57
  • it was very usefull answer, thank yuou. And i have one more question, how to make bigger gap between header line and main text? –  Aug 26 '13 at 12:41
  • 1
    @MindaugasTruklickas I'm glad it could help. For your new question take a look at http://tex.stackexchange.com/questions/85178/increase-height-of-fancyhdr-header and http://tex.stackexchange.com/questions/10896/define-different-heights-for-head-and-foot – sajjadG Aug 26 '13 at 12:46