这是同一篇文档的两页,图像 1 显示第 2 页,其中\section{Tareas realizadas}
与文本高度顶部重叠,而图像 2 显示第 3 页(正确行为)。
为什么第一个\section
与顶部边框重叠?
以下是代码(表格数据由外部 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
}
并且它按预期工作了!