简体   繁体   English

如何向 Sphinx 生成的 Latex 文档添加版权声明?

[英]How to add copyright notice to Sphinx generated Latex documentation?

I have set the copyright configuration value and it correctly appears in the HTML output.我已经设置了copyright配置值并且它正确地出现在 HTML 输出中。 However, it does not appear at all in the LaTeX output, and I can't find any option for LaTeX output that will make it appear.但是,它根本没有出现在 LaTeX 输出中,而且我找不到任何可以使其出现的LaTeX 输出选项

How can I automatically include the copyright notice in the LaTeX output, using Sphinx?如何使用 Sphinx 在 LaTeX 输出中自动包含版权声明? Of course, I could manually add it or write a small script to add it, but I expect it should be possible within the Sphinx framework.当然,我可以手动添加它或编写一个小脚本来添加它,但我希望它应该可以在 Sphinx 框架内实现。

Apparently, there is a request for improvement to make this easier.显然,需要改进以使其更容易。

If you want a copyright on each page (after title page and its back), you can do it with this mouthful of LaTeX macros (and sorry, it will ignore the copyright config value)如果您想要每个页面的版权(在标题页及其背面之后),您可以使用这一口 LaTeX 宏来实现(抱歉,它会忽略copyright配置值)

latex_elements = {
    'preamble': r'''
\makeatletter
   \fancypagestyle{normal}{
% this is the stuff in sphinx.sty
    \fancyhf{}
    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
% we comment this out and
    %\fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
    %\fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
% add copyright stuff
    \fancyfoot[LO,RE]{{This is \textcopyright\ 2019, Sphinx Team.}}
% again original stuff
    \fancyhead[LE,RO]{{\py@HeaderFamily \@title\sphinxheadercomma\py@release}}
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.4pt}
    }
% this is applied to each opening page of a chapter
   \fancypagestyle{plain}{
    \fancyhf{}
    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0.4pt}
% add copyright stuff for example at left of footer on odd pages,
% which is the case for chapter opening page by default
    \fancyfoot[LO,RE]{{This is \textcopyright\ 2019, Sphinx Team.}}
    }
\makeatother
''',
}

For more info on the LaTeX syntax see fancyhdr docs .有关 LaTeX 语法的更多信息,请参阅Fantasyhdr 文档 You have to LaTeX-escape yourself any worrisome character like $ .您必须使用 LaTeX 来逃避任何令人担忧的字符,例如$

Since Sphinx 1.8.3, you can put LaTeX material directly on back of title page (for 'manual' docclass, as there is no such notion for 'howto' docclass) via \\sphinxbackoftitlepage which is optional LaTeX macro you can define in 'preamble' or 'maketitle' .从 Sphinx 1.8.3 开始,您可以通过\\sphinxbackoftitlepage将 LaTeX 材料直接放在标题页的背面(对于'manual'文档类,因为'howto'文档类没有这样的概念),这是可选的 LaTeX 宏,您可以在'preamble'定义'preamble''maketitle' See docs (you need to scroll down to 'maketitle' ).查看文档(您需要向下滚动到'maketitle' )。

It seems to make indeed better sense to issue the copyright only at one location, so why not at back of title page as it is left empty by default.仅在一个位置发布版权似乎确实更有意义,那么为什么不在标题页后面,因为默认情况下它是空的。 ( 'manual' docclass) 'manual'文档类)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM