【问题标题】:How to add copyright notice to Sphinx generated Latex documentation?如何在 Sphinx 生成的 Latex 文档中添加版权声明?
【发布时间】:2019-06-06 09:59:39
【问题描述】:

我已经设置了copyright configuration value,它正确地出现在 HTML 输出中。但是,它根本没有出现在 LaTeX 输出中,而且我找不到任何可以让它出现的option for LaTeX output

如何使用 Sphinx 在 LaTeX 输出中自动包含版权声明?当然,我可以手动添加它或编写一个小脚本来添加它,但我希望在 Sphinx 框架内应该可以。

显然,有一个request for improvement 可以让这更容易。

【问题讨论】:

  • 请考虑 LaTeX 输出是单个文件,因此只有一页需要版权,就像任何印刷书籍一样。因此,为项目的版权、许可和其他元信息创建一个文件。

标签: latex python-sphinx copyright-display


【解决方案1】:

如果你想要每一页的版权(在标题页和它的背面之后),你可以用这个满嘴的 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
''',
}

有关 LaTeX 语法的更多信息,请参阅fancyhdr docs。您必须使用 LaTeX 来逃避任何令人担忧的角色,例如 $

从 Sphinx 1.8.3 开始,您可以通过 \sphinxbackoftitlepage 将 LaTeX 材料直接放在标题页的背面(对于 'manual' docclass,因为对于 'howto' docclass 没有这样的概念),这是可选的 LaTeX 宏,您可以在'preamble''maketitle' 中定义。见docs(你需要向下滚动到'maketitle')。

似乎只在一个位置发布版权确实更有意义,所以为什么不在标题页的后面,因为它默认为空。 ('manual'docclass)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-30
    • 1970-01-01
    • 1970-01-01
    • 2011-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多