2017-03-14 74 views
2

従来のマニュアルを再構築するために、Sphinxの機能を検討しています。私たちはすでに以前のマニュアルのほとんどをスフィンクスに移植しました。今私は会社スタイルを適応させる可能性を模索しています。Sphinxでラテックスのヘッダーとフッターをカスタマイズする

特に、PDFマニュアルでヘッダーとフッターの外観を変更したいと考えています。会社のロゴを含め、偶数ページと奇数ページの外観を変更します。

したがって、conf.pyには、fancyhdrパッケージを使用してカスタムパグスタイルで次のプリアンブルが含まれています。

latex_elements = { 
    'preamble' : '''\ 
     \\pagestyle{fancy} 
     \\fancyhf{} 
     \\fancyhead[LE,RO]{My Header}''' 
} 

残念ながら、begin{document}前のみ変更ヘッダは、その後スフィンクススタイルsphinx.styファイル何とか私の設定を上書きします。

sphinx.styから次のスニペットは、問題が発生することがあります:

% Redefine the 'normal' header/footer style when using "fancyhdr" package: 
\[email protected]{fancyhf}{}{ 
    % Use \pagestyle{normal} as the primary pagestyle for text. 
    \fancypagestyle{normal}{ 
    \fancyhf{} 
    \fancyfoot[LE,RO]{{\[email protected]\thepage}} 
    \fancyfoot[LO]{{\[email protected]\nouppercase{\rightmark}}} 
    \fancyfoot[RE]{{\[email protected]\nouppercase{\leftmark}}} 
    \fancyhead[LE,RO]{{\[email protected] \@title, \[email protected]}} 
    \renewcommand{\headrulewidth}{0.4pt} 
    \renewcommand{\footrulewidth}{0.4pt} 
    % define chaptermark with \@chappos when \@chappos is available for Japanese 
    \[email protected]{@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]{{\[email protected]\thepage}} 
    \renewcommand{\headrulewidth}{0pt} 
    \renewcommand{\footrulewidth}{0.4pt} 
    } 
} 

可能な回避策がありますか?

答えて

2

sphinxmanual.clsで)内容コードのテーブルが

\ifdefined\fancyhf\pagestyle{normal}\fi 

で終わるsphinx.styにコメントは述べています:

% Use \pagestyle{normal} as the primary pagestyle for text. 

したがって最も簡単なのは\fancypagestyle{normal}を上書きするためにあなたのconf.py設定にする必要があり、あなたの好きなところにそれを再発行するだけです。

\[email protected]を使用する場合は、ラテックス全体を\makeatletter...\makeatotherにラップする必要があります。また、すべてのバックスラッシュを二重にする必要がないように、Pythonの生の文字列を使用します。

関連する問題