有一个其他人创建的文档,我需要对其进行样式设置。
我正在使用 Sphinx-doc,下面是覆盖的 latex premable。我想自定义标题页。
latex_preamble = r'''
\usepackage{array}
\usepackage{graphicx}
\usepackage{pstricks}
\usepackage[postscript]{ucs}
\usepackage{xspace}
\usepackage{xcolor}
% Nimbus Samns L - helvetica clone
\setmainfont{Nimbus Sans L}
% Header and footer
\pagestyle{fancy}
\fancyhf{}
\definecolor{headercolor}{HTML}{8CC7EC}
\renewcommand{\headrule}{\color{headercolor}\hrule height 0.8pt}
\rhead{Technical Guide}
\lhead{\leftmark}
\lfoot{\copyright\xspace 2017. All rights reserved.}
\rfoot{\thepage}
% Table of Contents
% ToC: depth
\setcounter{secnumdepth}{4}
...
'''
latex_elements = {
'sphinxsetup': '',
'passoptionstopackages': r'\PassOptionsToPackage{table}{xcolor}',
'preamble': latex_preamble,
}
我的目标:
答案1
Sphinx-doc 允许您轻松覆盖某些 latex 元素。例如,在这种情况下,您想要自定义标题页。为此,您需要覆盖宏\maketitle
:
latex_maketitle = r'''
\begin{titlepage}
\noindent \Huge Example title \par
\sphinxlogo
\end{titlepage}
'''
# allow utf8 characters
latex_elements = {
'sphinxsetup': '',
'passoptionstopackages': r'\PassOptionsToPackage{table}{xcolor}',
'preamble': latex_preamble,
'maketitle': latex_maketitle,
}
在此示例中,结果将是您的标题+您使用的默认徽标图像。
原始的 Sphinx\maketitle
宏可以在这里找到:
% Change the title page to look a bit better, and fit in with the fncychap
% ``Bjarne'' style a bit better.
%
\renewcommand{\maketitle}{%
\noindent\rule{\textwidth}{1pt}\par
\begingroup % for PDF information dictionary
\def\endgraf{ }\def\and{\& }%
\pdfstringdefDisableCommands{\def\\{, }}% overwrite hyperref setup
\hypersetup{pdfauthor={\@author}, pdftitle={\@title}}%
\endgroup
\begin{flushright}
\sphinxlogo
\py@HeaderFamily
{\Huge \@title }\par
{\itshape\large \py@release \releaseinfo}\par
\vspace{25pt}
{\Large
\begin{tabular}[t]{c}
\@author
\end{tabular}}\par
\vspace{25pt}
\@date \par
\py@authoraddress \par
\end{flushright}
\@thanks
\setcounter{footnote}{0}
\let\thanks\relax\let\maketitle\relax
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
}
您可以据此进行更改以获得您想要的结果。