Here's an emacs defun to insert numbered figure using numfig:

(defun rst-bk-numfigs ()
  "Inserts numbered firgure in sphinx, using numfig extension:
https://bitbucket.org/arjones6/sphinx-numfig";
  (interactive) 

  (let (Fig Caption FigStripped FigStrippedLowerCase)

    (setq Fig (file-name-nondirectory 
               (car (list (read-file-name "Image file: "
                                          (if (file-exists-p "_static") ;; 
actually I need dir-p
                                              "_static"
                                            default-directory
                                            ))))))
    (setq Caption (read-from-minibuffer "Caption: "))

    (setq FigStripped 
          (replace-regexp-in-string "[^a-zA-Z]" ""
                                    (file-name-sans-extension Fig)))

    (with-temp-buffer
      (insert FigStripped)
      (downcase-region (point-min) (point-max))
      (setq FigStrippedLowerCase (buffer-substring-no-properties 
(point-min) (point-max))))

    (insert (format "\
:num:`Fig. #%s`

.. _%s:

.. figure:: _static/%s
   :width: 50%s
   :alt: %s
   :align: center

   %s
" FigStrippedLowerCase FigStrippedLowerCase Fig "%" Fig Caption)))
  (search-backward-regexp "`")
  (forward-char 1))



On Thursday, August 30, 2012 11:29:20 PM UTC+4, kt-fsi wrote:
>
> Is it somehow possible to have a figure caption different form the text of 
> the link to that figure?
>
> This may also help. It is a sphinx extension. We use this to have 'Figure 
> #' display in our HTML output: (numfig extension with the role, :num: )
>
> https://bitbucket.org/arjones6/sphinx-numfig/wiki/Home
>
> Kathy
> ka...@tolbert.org <javascript:>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-dev" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sphinx-dev/-/FAfXnuqgEV0J.
To post to this group, send email to sphinx-dev@googlegroups.com.
To unsubscribe from this group, send email to 
sphinx-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sphinx-dev?hl=en.

Reply via email to