섹션 수직 위치가 옮겨졌습니다.

섹션 수직 위치가 옮겨졌습니다.

여기에 동일한 문서의 두 페이지가 있습니다. 이미지 1은 \section{Tareas realizadas}텍스트 높이 상단과 겹치는 두 번째 페이지를 보여주고, 이미지 2는 세 번째 페이지를 보여줍니다(올바른 동작).

\section첫 번째 부분이 상단 테두리와 겹치는 이유는 무엇입니까 ?

이미지 1

이미지 2

코드는 다음과 같습니다(테이블 데이터는 외부 Python 프로그램에 의해 즉시 생성됩니다).

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

편집하다: 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.

내 fancypagestyle을 다음과 같이 수정했습니다.

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

그리고 예상대로 작동했습니다!.

답변1

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.

내 fancypagestyle을 다음과 같이 수정했습니다.

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

그리고 예상대로 작동했습니다!.

관련 정보