如何正确显示Sphinx文档生成器生成的pdf中的超链接 [英] How to correctly show hyperlinks in pdf generated from Sphinx documentation builder
问题描述
在 Sphinx 文档环境中,我正在使用 pdflatex 创建pdf文档.
From the Sphinx Documentation environment, I am creating a pdf document using pdflatex.
要在源文件之间导航,在某些文件中,我添加了使用label
和ref
的链接,这些链接在HTML文档中绝对可以正常工作.但是,上述链接不会显示在生成的pdf文件中.
To navigate between source files, in some of the files I have added links using label
and ref
which work abosolutely fine in the HTML documentation. However, the said links do not show up in the generated pdf file.
我正在复制我的.rst
文件(的一部分),它们之间具有 reference :
I am reproducing (part of) my .rst
files with reference between them:
文件 define_ques_list.rst (从该文件中,我称为文件capa.rst
)
File define_ques_list.rst (From this file I call the file capa.rst
)
###################
Question List
###################
**Definition**
Question lists are multilingual collections of questions that are answered during the exe...
:ref:`CAPA <corr-n-prev-action-capa-label>`
.. index:: question list
文件 capa.rst
.. _corr-n-prev-action-capa-label:
##########################
CAPA
#########################
Corrective Actions/Preventive Actions
-------------------------------------
**Definition**
*Corrective Actions*
These are actions that are deemed necessary to eliminate the cause of errors that were determined dur...
*Preventive Actions*
These are actions that are deemed necessary to eliminate the causes of possible errors before they ...
.. index:: corrective action CAPA
我检查了文件*.tex
中的(相关)内容,可以看到以下内容:
I checked the (relevant) contents in file *.tex
and can see the following:
\chapter{Question List}
\label{\detokenize{modules/definitions/define_ques_list:question-list}}\label{\detokenize{modules/definitions/define_ques_list:question-list-href-label}}\label{\detokenize{modules/definitions/define_ques_list::doc}}
\sphinxstylestrong{Definition}
Question lists are multilingual collections of questions that are answered during the exe...
\DUrole{xref,std,std-ref}{CAPA} <= This is the hyperlink as translated?
\index{question list@\spxentry{question list}}\ignorespaces
我的问题是:为什么pdf文件中缺少我的超链接?
My question is: Why are my hyperlinks missing from the pdf file?
推荐答案
感谢@mzjn和@Trendfischer,提出了以下解决方案:
Thanks to @mzjn and @Trendfischer, came up with the following solution:
使用 index.rst 中的指令:hidden:
,将 referred 添加到文件 capa.rst 中,如下所示:
Using the directive :hidden:
in index.rst, added the referred to file capa.rst as shown:
index.rst
.. xyz documentation master file, created by
sphinx-quickstart on...
You can adapt this file....
XYZ documentation
===================
.. toctree::
:maxdepth: 2
:caption: Help Contents:
modules/abc.rst
modules/definitions/define_ques_list.rst
help_on_help.rst
.. toctree:: <= New line
:hidden: <= New line
modules/definitions/capa.rst. <= New line
通过这种安排,我现在在生成pdf文件时将超链接链接到被调用文件( capa.rst ).
With this arrangement, I am now getting the hyperlink to the called file (capa.rst) when pdf file is generated.
这篇关于如何正确显示Sphinx文档生成器生成的pdf中的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!