3

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.

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
gerrit
  • 24,025
  • 17
  • 97
  • 170
  • 2
    Consider that LaTeX output is a single file, and therefore a copyright is necessary on only one page, just like any printed book. As such, create a file for copyright, license, and other meta information about the project. – Steve Piercy Jan 11 '19 at 14:00

1 Answers1

3

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
''',
}

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

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').

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)