gpt4 book ai didi

pdf - Sphinx LaTeX PDF 中的目录侧边栏

转载 作者:行者123 更新时间:2023-12-04 12:49:28 25 4
gpt4 key购买 nike

我正在从 Sphinx 生成 LaTeX 文档,并使用 pdflatex(来自 MikTeX)将其转换为 PDF。该文档在 PDF 查看器的边栏中缺少目录。

如果我手动添加 \usepackage{hyperref}到 tex 文件,它的工作原理。但是我怎么能告诉 Sphinx 在 conf.py 项目文件中做呢? latex 输出选项中没有(明显的)相关选项。

谢谢!

最佳答案

栏目 2.5.3 自定义渲染 Sphinx 文档中提到:

LaTeX preamble

Additional commands may be added as preamble in the generated LaTeX file. This is easily done by editing file conf.py:

f = open('latex-styling.tex', 'r+');
PREAMBLE = f.read();

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'a4paper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
'preamble': PREAMBLE
}

This will copy the contents of file latex-styling.tex (in same directory as conf.py) to the generated LaTeX document. For instance, if latex-styling.tex reads:

% My personal "bold" command
\newcommand{\mycommand}[1]{\textbf{#1}}

the generated LaTeX document becomes:

% Generated by Sphinx.
\def\sphinxdocclass{report}
\documentclass[a4paper,10pt,english]{sphinxmanual}
% snip (packages)
% My personal "bold" command
\newcommand{\mycommand}[1]{\textbf{#1}}
\title{My Extension Documentation}
\date{2013-06-30 22:25}
\release{1.0.0}
\author{Xavier Perseguers}

Other options

The configuration file conf.py lets you further tune the rendering with LaTeX. Please consult http://www.sphinx-doc.org/en/stable/config.html#options-for-latex-output for further instructions.


添加内容而不是将其插入单独的文件(例如 latex-styling.tex )的一种更直接的方法是逐字指定。文档中的下一小节针对特定的包 typo3 提到了这一点。 :

TYPO3 template

We want to stick as much as possible to default rendering, to avoid having to change the LaTeX code generation from Sphinx. As such, we choose to include a custom package typo3 (file typo3.sty) that will override some settings of package sphinx. To include it automatically, we simply use the preamble option of conf.py:

latex_elements = {
# Additional stuff for the LaTeX preamble.
'preamble': '\\usepackage{typo3}'
}

最好将您的样式选项包含在单独的 latex-styling.tex 中您可以使用 preamble 包含的文件 key 通过 f.read() .这样您就不必更新 conf.py .分区化通常更好。

关于pdf - Sphinx LaTeX PDF 中的目录侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32335040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com