A posição vertical da seção está deslocada

A posição vertical da seção está deslocada

Aqui estão duas páginas do mesmo documento, a Imagem 1 mostra a 2ª página, onde \section{Tareas realizadas}está sobreposta a altura do texto, enquanto a Imagem 2 mostra a 3ª página (comportamento correto).

Por que o primeiro está \sectionsobreposto à borda superior?

Imagem 1

Imagem 2

Aqui está o código (os dados da tabela são gerados dinamicamente por um programa Python externo):

% use article styling for this document
\documentclass[11pt,a4paper]{article}

% enable system font access
\usepackage{fontspec}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage[spanish]{babel}
% agregar showframe para ver los márgenes
\usepackage[showframe, top=3cm, bottom=3cm, left=2cm, right=2cm]{geometry}
\usepackage{tocloft}
\usepackage{xcolor,colortbl}
\usepackage{longtable}
\usepackage{titlesec}

\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{RGB}{60,179,113}

\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\fancypagestyle{myheader}{%
  \fancyhf{}% Clear all headers/footers
  \fancyhead[C]{Informe Semanal - \input{fecha.dat}}% Header Centred
  \fancyfoot[R]{\thepage /\pageref{LastPage}}% Footer Centred
  \renewcommand{\headrulewidth}{2pt}% 2pt header rule
  \renewcommand{\headrule}{\hbox to\headwidth{%
    \color{LightCyan}\leaders\hrule height \headrulewidth\hfill}}
  \renewcommand{\footrulewidth}{0pt}% No footer rule
}

% styling: Palatino (main text), Helvetica (stress)
\setmainfont{OptimaLTStd}
\newfontfamily{\maintext}{OptimaLTStd}
\newfontfamily{\stressed}{HelveticaLTStd-Roman}

% start of actual document
\renewcommand{\abstractname}{Sumario}

\begin{document}

  \pagestyle{myheader}
  \begin{titlepage}
    \setcounter{page}{0}

    \title{Informe semanal}
    \author{Leonardo M. Ramé\\ Medical I.T.}
    \immediate\write18{./get_date.sh > fecha.dat}
    \date{\input{fecha.dat}}
    \maketitle 

    \renewcommand\contentsname{Tabla de contenidos}
    \tableofcontents

    \section*{Resumen}
    \immediate\write18{./get_agregados.sh > temp.dat}
    \input{temp.dat}

  \thispagestyle{empty}
  \end{titlepage}

%\titleformat{name=\section}[block]
%  {}
%  {}
%  {0pt}
%  {\colorsection}

%\titlespacing{\section}{0pt}{\baselineskip}{\baselineskip}

%\newcommand{\colorsection}[1]{%
%  \colorbox{Gray}{\parbox{\dimexpr\textwidth-2\fboxsep}{\thesection\ #1}}}

\newpage
\section{Tareas realizadas}

% generamos el listado y lo guardamos en temp.dat
\immediate\write18{./get_reports.sh closed|python parser.py CLOSED > temp.dat}
\input{temp.dat}

\newpage
\section{Tareas pendientes}

% generamos el listado y lo guardamos en temp.dat
\immediate\write18{./get_reports.sh open|python parser.py OPEN > temp.dat}
\input{temp.dat}

\end{document}

Editar: Aqui está o aviso do Fancyhdr

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least 23.11996pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

Modifiquei meu estilo de página extravagante para isto:

\fancypagestyle{myheader}{%
  \fancyhf{}% Clear all headers/footers
  \setlength{\headheight}{40pt}
  \setlength{\textheight}{620pt}
  \fancyhead[C]{Informe Semanal - \input{fecha.dat}}% Header Centred
  \fancyfoot[R]{\thepage /\pageref{LastPage}}% Footer Centred
  \renewcommand{\headrulewidth}{2pt}% 2pt header rule
  \renewcommand{\headrule}{\hbox to\headwidth{%
    \color{LightCyan}\leaders\hrule height \headrulewidth\hfill}}
  \renewcommand{\footrulewidth}{0pt}% No footer rule
}

E funcionou como esperado!

Responder1

Aqui está o aviso do Fancyhdr

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least 23.11996pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

Modifiquei meu estilo de página extravagante para isto:

\fancypagestyle{myheader}{%
  \fancyhf{}% Clear all headers/footers
  \setlength{\headheight}{40pt}
  \setlength{\textheight}{620pt}
  \fancyhead[C]{Informe Semanal - \input{fecha.dat}}% Header Centred
  \fancyfoot[R]{\thepage /\pageref{LastPage}}% Footer Centred
  \renewcommand{\headrulewidth}{2pt}% 2pt header rule
  \renewcommand{\headrule}{\hbox to\headwidth{%
    \color{LightCyan}\leaders\hrule height \headrulewidth\hfill}}
  \renewcommand{\footrulewidth}{0pt}% No footer rule
}

E funcionou como esperado!

informação relacionada