sphinx customization of latexpdf output?

送分小仙女□ 提交于 2019-12-18 10:36:14

问题


Just curious if anyone knows how to customize the sphinx output when using the latexpdf target? I've seen lots of custom stuff for html output, but cant seem to find any example of custom pdf output.

Specifically, I'd be interested in customizing the title page, headers, footers, and possibly adding a few pages of front matter before the contents.

Has anyone seen any examples of this kind of customization, or do people pretty much just use the "stock" sphinx output when generating pdfs? Thanks!


回答1:


Yes i think better or clearer documentation for latex styling would be nice and some examples.

Here is a question on the sphinx mailing list, which is about about using packages.

sphinx has its own latex documentclass in a file called sphinxmanual.cls or sphinxhowto.cls, if i remember correctly its a report documentclass that is used as base. then there is 2 style files, which are the packages, it is those files contents that are called on when you write \usepackage{mylatexstilefile}

Question about using latex packages http://groups.google.com/group/sphinx-dev/browse_thread/thread/890dab5e53fff004

Here is my conf.py.

preamb_old = ur'''
  %\documentclass{memoir}
  \makeatletter
  \fancypagestyle{normal}{
    \fancyhf{}
    \fancyfoot[LE,RO]{{\py@HeaderFamily\thepage}}
    \fancyfoot[LO]{{\py@HeaderFamily\nouppercase{\rightmark}}}
    \fancyfoot[RE]{{\py@HeaderFamily\nouppercase{\leftmark}}}
    \fancyhead[LE,RO]{{\py@HeaderFamily \@title}} % here's the change
    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\footrulewidth}{0.4pt}
  }
  \makeatother
  %\color {blue}
  %\normalcolor {dark blue}
  \pagecolor [RGB]{255, 247, 226}
  \definecolor{VerbatimColor}{rgb}{0.95,0.85,0.65}
  \definecolor{VerbatimBorderColor}{rgb}{0.5,0.95,0.1}
'''

f = open('graph/static/latexstyling.tex', 'r+')
PREAMBLE = f.read();


latex_elements = {
   'papersize':'a4paper',
   'pointsize':'11pt',
   'classoptions': ',openany',
   'babel': '\\usepackage[english]{babel}',
   'preamble': PREAMBLE

}

i don't use preamble_old anymore, but it is an example of changes directly in conf.py, to your latex preamble.

Check out latex_elements and latex_additional_files in the sphinx docs as a starting point.



来源:https://stackoverflow.com/questions/4839105/sphinx-customization-of-latexpdf-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!