I am trying to use the numfig extension for getting numbered referenced 
figures while generating both HTML and PDF documentation and so far this 
has worked great.

Now, I would like to use PDF figures in the latex version and PNG figures 
in the html version. I tried to use the .. only:: directive as follows

.. only:: html

   .. _import-dmmetamodel:

   .. figure:: _static/dataext/DM-Example.png

      My caption for the figure.
.. only:: latex

   .. _import-dmmetamodel:

   .. figure:: _static/dataext/DM-Example.pdf

      My caption for the figure.

If I do this, then the HTML version works (probably because it is first) 
but the latex version breaks the numfig reference (showing ?? questions 
marks in the latex-generated PDF doc where the reference should be).

In the latex code the figure label \label{dataext:id1} is generated instead 
of the label \label{dataext:import-dmmetamodel}, I assume because of the 
duplication of the .. _import-dmmetamodel: line.

This of course breaks the numfig in-line text reference which is properly 
resolved to \hyperref[dataext:import-dmmetamodel]{Figure 
\ref*{dataext:import-dmmetamodel}}.

So, I tried to avoid the duplication by doing this

.. _import-dmmetamodel:
.. only:: html

   .. figure:: _static/dataext/DM-Example.png

      My caption for the figure.
.. only:: latex

   .. figure:: _static/dataext/DM-Example.pdf

      My caption for the figure.

However, now I get this error message:

Exception occurred: File "/MyPath/Documentation/sphinxext/numfig.py", line 
76, in doctree_resolved target_doc = 
app.builder.env.figid_docname_map[target] KeyError: u'import-dmmetamodel'

Is this a problem with numfig or am I doing something wrong here? Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to