Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python sphinx SPHINX-numref适用于HTML,但不适用于LaTex_Python Sphinx_Pdflatex_Pdftex - Fatal编程技术网

Python sphinx SPHINX-numref适用于HTML,但不适用于LaTex

Python sphinx SPHINX-numref适用于HTML,但不适用于LaTex,python-sphinx,pdflatex,pdftex,Python Sphinx,Pdflatex,Pdftex,我正在从事一个Sphinx软件文档项目,其中包括很多数字。 我用“numref”来指代图片。在HTML中,它工作得很好。在乳胶中我得到无花果?? 网络上关于numref的问题很少,答案对我没有帮助。 有人能告诉我我做错了什么吗 我用Sphinx quickstart安装了Sphinx环境。 my conf.py中的相关行包括: # Conf.py # Automatic numbering numfig = True # -- Options for LaTe

我正在从事一个Sphinx软件文档项目,其中包括很多数字。 我用“numref”来指代图片。在HTML中,它工作得很好。在乳胶中我得到无花果?? 网络上关于numref的问题很少,答案对我没有帮助。 有人能告诉我我做错了什么吗

我用Sphinx quickstart安装了Sphinx环境。 my conf.py中的相关行包括:

    # Conf.py

    # Automatic numbering
    numfig = True

    # -- Options for LaTeX output ------------------------------------------------

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

        # Latex figure (float) alignment
        # 'figure_align': 'htbp',
        'figure_align': 'H' # disable floating
    }

    # Grouping the document tree into LaTeX files. List of tuples
    # (source start file, target name, title,
    #  author, documentclass [howto, manual, or own class]).

    latex_documents = [
        (master_doc, 'PDF_Test.tex', 'PDF generation',
         'Niels de Nies', 'manual'),
    ]
我的源(index.rst)看起来像:

    #########################
    Sphinx numref Test
    #########################

    My first chapter
    ----------------

    The purpose of this test is to get the numref of figures working in LaTex.

    Section 1
    ~~~~~~~~~
    .. figure:: ../images/hippo.png
        :name: hippo

    :numref:`hippo` Hippopotamus    

    The figure above (:numref:`hippo`) shows an illuminated hippopotamus.

    The 'numref' works fine in HTML, but results in Fig. ?? with LaTex

    Below the alternative way using a label. The results are exactly the same:
    Perfect for HTML, but undefined reference for latexpdf

    .. _fig_hippo:

    .. figure:: ../images/hippo.png
        :name: hippo

    :numref:`fig_hippo` Hippopotamus    
在命令行上显示:

    === TeX engine is 'pdfTeX'
    Latexmk: Index file 'PDF_Test.idx' was written
    Latexmk: Log file says output to 'PDF_Test.pdf'
    Latexmk: List of undefined refs and citations:
      Reference `index:hippo' on page 1 undefined on input line 111
      Reference `index:hippo' on page 1 undefined on input line 113
    Latexmk: Summary of warnings from last run of (pdf)latex:
      Latex failed to resolve 2 reference(s)
    Latexmk: All targets () are up-to-date
在生成的PDF_Test.tex中,以下行给出了问题:

    \hyperref[\detokenize{index:hippo}]{Fig.\@ \ref{\detokenize{index:hippo}}} Hippopotamus

    The figure above (\hyperref[\detokenize{index:hippo}]{Fig.\@ \ref{\detokenize{index:hippo}}}) shows an illuminated hippopotamus.

有谁能告诉我怎么解决这个问题吗?

花了很多时间,但我终于找到了答案。 源代码应如下所示:

    .. figure:: ../images/hippo.png
        :name: hippo

        Hippopotamus    

    The figure above (:numref:`hippo`) shows an illuminated hippopotamus.
以HTML和PDF格式显示,如:


花了很多时间,但我终于找到了答案。 源代码应如下所示:

    .. figure:: ../images/hippo.png
        :name: hippo

        Hippopotamus    

    The figure above (:numref:`hippo`) shows an illuminated hippopotamus.
以HTML和PDF格式显示,如:


或者,换句话说,对于:numref:要正常工作,该图需要标题文本。生成HTML时,如果有标题文本,您会看到“图2.1:河马”,如果您不使用它,则HTML:numref:link仍然有效,但图下方的标题丢失。对于PDF输出,需要标题。(如果您注意到,您还收到了来自latexpdf的“缺少参考”警告。)

或者,换句话说,为了:numref:正常工作,该图需要标题文本。生成HTML时,如果有标题文本,您会看到“图2.1:河马”,如果您不使用它,则HTML:numref:link仍然有效,但图下方的标题丢失。对于PDF输出,需要标题。(如果您注意到,您还收到了来自latexpdf的“缺少参考”警告。)

请不要粘贴日志文件的图像。粘贴实际文本。同时检查Sphinx问题跟踪器。我查看了问题跟踪程序,但只有一个问题与我的问题类似。但建议的“变通办法”对我不起作用。肯定有一个名称选项。我在index.rst的底部添加了另一种方法,即使用标签。但结果是一样的。请提交解决方案作为答案。请不要粘贴日志文件的图像。粘贴实际文本。同时检查Sphinx问题跟踪器。我查看了问题跟踪程序,但只有一个问题与我的问题类似。但建议的“变通办法”对我不起作用。肯定有一个名称选项。我在index.rst的底部添加了另一种方法,即使用标签。但结果是一样的。请提交解决方案作为答案。