Figure caption problem with numfig

344 views
Skip to first unread message

Warren Block

unread,
Aug 10, 2016, 8:53:14 PM8/10/16
to sphinx...@googlegroups.com
Trying to figure out where an extra "Figure 1" is appearing in figure
captions. For example

:numref:`Figure %s <fig1>` shows what we are talking about.

.. _fig1

.. figure:: images/sample.png

Sample Caption

The HTML produced (wrapped for clarity):

<p class="caption">
<span class="caption-number">Fig. 3.1.1 </span>
<span class="caption-text">Figure 1: Sample Caption</span>
</p>

conf.py just has

numfig = True
numfig_secnum_depth = (2)

I don't see "Figure" in the CSS.

Any idea on where that extra "Figure 1:" is coming from?

Thanks!

Peter Burdine

unread,
Aug 11, 2016, 10:48:59 AM8/11/16
to sphinx-users
Did you define (or un-define) the numfig_format in your conf.py?

numfig_format = {'figure': 'Figure %s',
                 
'table': 'Table %s',
                 
'code-block': 'Code %s',
               
}

Warren Block

unread,
Aug 11, 2016, 4:27:45 PM8/11/16
to sphinx-users
On Thu, 11 Aug 2016, Peter Burdine wrote:

> Did you define (or un-define) the numfig_format in your conf.py?
>
> numfig_format = {'figure': 'Figure %s',
>                  'table': 'Table %s',
>                  'code-block': 'Code %s',
>                 }

No, I tried this but these were all still added, so there were two
"Figure" entries. And setting 'figure' to an empty string made it very,
very unhappy.

The answer was adding

numfig_number_figures = False

to conf.py. Why are figures are different? Don't know, but this does
what is needed for now.

Komiya Takeshi

unread,
Aug 11, 2016, 9:03:33 PM8/11/16
to sphinx-users
Hi,

Do you use sphinxtr/numfig.py? It appends "Figure n:" automatically.
https://github.com/jterrace/sphinxtr/blob/master/extensions/numfig.py#L124

Please tell me what extensions you are using.

Thanks,
Takeshi KOMIYA

2016年8月12日金曜日 5時27分45秒 UTC+9 Warren Block:

Warren Block

unread,
Aug 11, 2016, 11:25:05 PM8/11/16
to sphinx-users
On Thu, 11 Aug 2016, Komiya Takeshi wrote:

> Hi,
> Do you use sphinxtr/numfig.py? It appends "Figure n:" automatically.
> https://github.com/jterrace/sphinxtr/blob/master/extensions/numfig.py#L124
>
> Please tell me what extensions you are using.

The port is from here:
https://bitbucket.org/arjones6/sphinx-numfig/wiki/Home

In conf.py:

extensions = [
'sphinx.ext.ifconfig',
'sphinxcontrib.httpdomain',
'sphinx.ext.numfig'
]

Komiya Takeshi

unread,
Aug 12, 2016, 12:58:06 AM8/12/16
to sphinx-users
Since Sphinx-1.3, Sphinx provides numfig feature as a built-in.
So no extensions are needed now.

It will go well if you remove the sphinx-numfig extension.

Thanks,
Takeshi KOMIYA

2016年8月12日金曜日 12時25分05秒 UTC+9 Warren Block:

Warren Block

unread,
Aug 16, 2016, 12:29:35 AM8/16/16
to sphinx-users
On Thu, 11 Aug 2016, Komiya Takeshi wrote:

> Since Sphinx-1.3, Sphinx provides numfig feature as a built-in.
> So no extensions are needed now.
>
> It will go well if you remove the sphinx-numfig extension.

Absolutely right. Thank you!
Reply all
Reply to author
Forward
0 new messages