【发布时间】:2017-03-14 13:32:59
【问题描述】:
我们正在探索 Sphinx 的功能,以重建我们的旧手册。我们已经将大部分以前的手册移植到了 Sphinx。现在我正在探索调整我们公司风格的可能性。
特别是,我们想更改 PDF 手册中页眉和页脚的外观。包括公司徽标并更改偶数页和奇数页的外观。
因此,我在 conf.py 中包含以下序言,并使用包 fancyhdr 自定义页面样式。
latex_elements = {
'preamble' : '''\
\\pagestyle{fancy}
\\fancyhf{}
\\fancyhead[LE,RO]{My Header}'''
}
不幸的是,标题仅在 begin{document} 之前更改,之后 Sphinx 样式文件 sphinx.sty 以某种方式覆盖了我的设置。
sphinx.sty 的以下 sn-p 可能会导致问题:
% Redefine the 'normal' header/footer style when using "fancyhdr" package:
\spx@ifundefined{fancyhf}{}{
% Use \pagestyle{normal} as the primary pagestyle for text.
\fancypagestyle{normal}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
\fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
\fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
\fancyhead[LE,RO]{{\py@HeaderFamily \@title, \py@release}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
% define chaptermark with \@chappos when \@chappos is available for Japanese
\spx@ifundefined{@chappos}{}
{\def\chaptermark##1{\markboth{\@chapapp\space\thechapter\space\@chappos\space ##1}{}}}
}
% Update the plain style so we get the page number & footer line,
% but not a chapter or section title. This is to keep the first
% page of a chapter and the blank page between chapters `clean.'
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
}
}
可能的解决方法是什么?
【问题讨论】:
标签: latex python-sphinx tex pdflatex