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!

5
  • 1
    It's not enough; please make a minimal working example (MWE)
    – egreg
    Commented Aug 22, 2013 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
    – user34480
    Commented Aug 22, 2013 at 13:45
  • Click the hyper link in @egreg's comment.
    – dustin
    Commented Aug 22, 2013 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
    Commented Aug 22, 2013 at 14:40
  • I had this issue because I included \usepackage{fullpage} Commented Dec 14, 2018 at 16:20

1 Answer 1

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
4
  • 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
    Commented Aug 23, 2013 at 7:51
  • @MBR I had this problem and solve it by this code. I updated with my working copy. place this before \begin{document}
    – sajjadG
    Commented Aug 23, 2013 at 7: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?
    – user34480
    Commented Aug 26, 2013 at 12:41
  • 1
    @MindaugasTruklickas I'm glad it could help. For your new question take a look at tex.stackexchange.com/questions/85178/… and tex.stackexchange.com/questions/10896/…
    – sajjadG
    Commented Aug 26, 2013 at 12:46

You must log in to answer this question.