如何在Sphinx生成的Latex文档中添加版权声明? [英] How to add copyright notice to Sphinx generated Latex documentation?

查看:167
本文介绍了如何在Sphinx生成的Latex文档中添加版权声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已设置 copyright 配置值,它会正确显示在HTML输出中.但是,它根本不会出现在LaTeX输出中,并且我找不到任何

I have set the copyright configuration value and it correctly appears in the HTML output. 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.

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

How can I automatically include the copyright notice in the LaTeX output, using Sphinx? 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.

显然,有一个要求改进,以使此操作变得容易.

Apparently, there is a request for improvement to make this easier.

推荐答案

如果你想要每一页的版权(在标题页和它的背面之后),你可以用这满口的 LaTeX 宏来做到(对不起,它会忽略 copyright 配置值)

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_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文档.您必须使用LaTeX逃避任何令人担忧的字符,例如 $ .

For more info on the LaTeX syntax see fancyhdr docs. You have to LaTeX-escape yourself any worrisome character like $.

自Sphinx 1.8.3起,您可以将LaTeX材质直接放在标题页的背面(对于'manual' docclass,因为对于'howto' docclass) 通过 \sphinxbackoftitlepage 这是可选的 LaTeX 宏,您可以在 'preamble''maketitle' 中定义.参见文档(您需要向下滚动到'maketitle').

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'. See docs (you need to scroll down to 'maketitle').

仅在一个位置发布版权似乎确实更好,所以为什么不在标题页的后面发布版权,因为默认情况下它是空白的.('manual' docclass)

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)

这篇关于如何在Sphinx生成的Latex文档中添加版权声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆