平均能量损失

平均能量损失

我已开始使用 LyX 编写技术规范文档。经过多次匆忙的 Google 搜索(许多搜索都以这个网站结束),我拼凑了一个 LyX 文件,它基本上满足了我的要求。

但是,我发现当我使用 xetex 将其呈现为 PDF 时,标题后的第一页(一部分)似乎总是相对于其他页面垂直错位。

问题:我忽略了什么/弄错了什么?



请注意,我在序言中添加了一些内容,使部分看起来像章节(不再记得为什么了)。

我的 MWE 如下,如果您使用 XeTeX 将其处理为 PDF,您会发现“文档控制”的标题相对于“背景信息”垂直错位。我的所有其他部分(不在 MWE 中)与“背景信息”部分对齐。我的测试表明,哪个是第一部分并不重要 - 它总是错位(在 OSX Preview.app 中使用 2 页视图查看):

在此处输入图片描述

错位延伸到页脚。因此,就像整个页面主体在垂直方向上被提升了几个像素

我发现改变标题图像(logo.png)的大小会导致错位的比例发生变化。

作为 TeX 的新手,我无法解释这一点。


平均能量损失

logo.png 尺寸为 464px x 60px

文档类是report

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass report
\begin_preamble
\usepackage[a4paper]{geometry}
\usepackage[table]{xcolor}
\usepackage{background}

\usepackage{lastpage}
\usetikzlibrary{calc,shapes,arrows}


%tables
\arrayrulecolor[RGB]{127,127,127}
\setlength{\arrayrulewidth}{0.25mm}




\usepackage[explicit]{titlesec}

% make part like a chapter
\titleclass{\part}{top} 
\titleformat{\part}
[display]
{\normalfont\Huge\bfseries}
{\titlerule[5pt]\vspace{3pt}\titlerule[2pt]\vspace{3pt}\MakeUppercase{\partname} \thepart}
{0pt}
{\titlerule[2pt]\vspace{1pc}\huge\MakeUppercase{#1}}
\titlespacing*{\part}{0pt}{0pt}{20pt}


% make chapter like a section (no newpage)
\titleclass{\chapter}{straight} 
\titleformat{\chapter}
[display]
{\centering\normalfont\Huge\bfseries}
{\titlerule[5pt]\vspace{3pt}\titlerule[2pt]\vspace{3pt}\MakeUppercase{\chaptertitlename} \thechapter}
{0pt}
{\titlerule[2pt]\vspace{6pt}\huge\MakeUppercase}
\titlespacing*{\chapter}{0pt}{0pt}{40pt}

% make section have a background 
\titleformat{\section}
[display]
{\normalfont\Large\bfseries}
{\thesection}
{0pt}
{\colorbox{blue!20}{\parbox{\dimexpr\textwidth-2\fboxsep}{#1}}}
%


% make subsubsection italicised
\titleformat{\subsubsection}
[display]
{\normalfont\bfseries}
{\thesubsubsection}
{0pt}
{\textit{#1}}
%

%Document variables
\newcommand*{\customer}{Foo}
\newcommand*{\customerlong}{Bar}
\newcommand*{\docversion}{Draft Version 0.0.1}

%Page footer - horiz line
\def\footrule{{
  \vskip-\footruleskip\vskip-\footrulewidth
  \color{\footrulecolor}
  \hrule\@width\headwidth\@height
  \footrulewidth\vskip\footruleskip
}}

%page borders
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{12pt}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\newcommand{\footrulecolor}{blue}

%page candy
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[C]{\includegraphics{logo.png}}
%\fancyfoot[C]{\bfseries \thepage} % except the center
\fancyfoot[L]{\textbf{\textcolor{orange}{\scriptsize Confidential}}}
\fancyfoot[C]{\textbf{\textcolor{blue}{\Large website.com}} }
\fancyfoot[R]{\textbf{\textcolor{orange}{\scriptsize Page \thepage\ of \pageref{LastPage} }} }
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\footrulecolor}{blue}
}
\end_preamble
\options demo
\use_default_options true
\begin_modules
theorems-ams
eqs-within-sections
figs-within-sections
customHeadersFooters
\end_modules
\maintain_unincluded_children false
\begin_local_layout

\end_local_layout
\language british
\language_package default
\inputencoding auto
\fontencoding global
\font_roman lmodern
\font_sans lmss
\font_typewriter lmtt
\font_default_family sfdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics xetex
\default_output_format pdf4
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize 12
\spacing single
\use_hyperref false
\papersize a4paper
\use_geometry true
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 2cm
\topmargin 2cm
\rightmargin 2cm
\bottommargin 4.75cm
\headsep 1cm
\footskip 2.5cm
\secnumdepth -1
\tocdepth 0
\paragraph_separation skip
\defskip 16pt
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Center Header
\begin_inset Graphics
    filename logo.png

\end_inset


\end_layout

\begin_layout Center Footer
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
textbf{
\backslash
textcolor{blue}{
\backslash
Large website.com}}
\end_layout

\end_inset


\end_layout

\begin_layout Left Footer
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
textbf{
\backslash
textcolor{orange}{
\backslash
scriptsize Confidential}}
\end_layout

\end_inset


\end_layout

\begin_layout Right Footer
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
textbf{
\backslash
textcolor{orange}{
\backslash
scriptsize Page 
\backslash
thepage
\backslash
 of 
\backslash
pageref{LastPage} }}
\end_layout

\end_inset


\end_layout

\begin_layout Title
\begin_inset Graphics
    filename logo.png

\end_inset


\begin_inset Newline newline
\end_inset

Specification
\begin_inset Newline newline
\end_inset


\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
docversion
\end_layout

\end_inset


\begin_inset Newline newline
\end_inset


\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash

\end_layout

\end_inset


\begin_inset Newline newline
\end_inset


\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
customerlong
\end_layout

\end_inset


\begin_inset Newline newline
\end_inset

A Title
\end_layout

\begin_layout Part*

\lang english
Document Control
\end_layout

\begin_layout Section*

\lang english
Copyright
\end_layout

\begin_layout Standard

\lang english
Generic blurb
\end_layout

\begin_layout Section*

\lang english
Document Version History
\end_layout

\begin_layout Standard
a table
\end_layout

\begin_layout Part*
Background Information
\end_layout

\begin_layout Section*
Project Taxonomy
\end_layout

\begin_layout Standard
a table
\end_layout

\begin_layout Section*
Stakeholders
\end_layout

\begin_layout Itemize
List of direct project stakeholders
\end_layout

\begin_layout Section*
Other Parties
\end_layout

\begin_layout Itemize
List of ancialliary parties
\end_layout

\begin_layout Section*
Exclusions
\end_layout

\begin_layout Standard
Generic stuff
\end_layout

\begin_layout Section*
Another Heading
\end_layout

\begin_layout Standard
Some useful information
\end_layout

\begin_layout Section*
Another Heading
\end_layout

\begin_layout Standard
Some useful information
\end_layout

\begin_layout Section*
Another Heading
\end_layout

\begin_layout Standard
Some useful information
\end_layout

\end_body
\end_document


更新

进一步的测试表明,只需在标题后面添加一些纯文本就会产生相同的偏移效果 - 因此问题不在于零件定义。

答案1

编译文档后,打开日志(文档 --> LaTeX 日志),并逐步查看警告。您可能会发现类似这样的警告

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

这解释了问题是什么、应该做什么来解决它,以及为什么该问题第一次只出现一次\part

\headheight页眉的高度,您在前言中将其设置为12pt( \setlength\headheight{12pt})。这不足以容纳页眉中的图像,因此对于包含第一个的页面,\part页眉将溢出分配的空间。正如警告所述,在此页之后,\headheightLaTeX 会修改 ,因此对于接下来的页面,不会出现此问题。

要修复此问题,请将\headheight前言中的 更改为(至少)日志中报告的值。报告的确切值取决于标题内容的大小,因此请检查您自己的日志——我为测试插入了不同的图像。

相关内容