jkitchin / org-ref

org-mode modules for citations, cross-references, bibliographies in org-mode and useful bibtex tools to go with it.
GNU General Public License v3.0
1.37k stars 244 forks source link

Referencing subfigures #530

Closed suyashbire1 closed 3 years ago

suyashbire1 commented 6 years ago

If a figure fig:fig1 has, say, four panels, in latex one would do \ref{fig:fig1}a to reference the first panel. In org-ref, one would do ref:fig:fig1 a, which in latex translates to \ref{fig:fig1} a. In my opinion, figure 1a looks much cleaner than figure 1 a.

Is there an easy way to get rid of that space between } and a?

jagrg commented 6 years ago

You can add a label inside the subfigure environment and reference that label as usual. No need to add the extra letter.

On 19 Dec 2017, Suyash Bire notifications@github.com wrote:

If a figure fig:fig1 has, say, four panels, in latex one would do \ref{fig:fig1}a to reference the first panel. In org-ref, one would do ref:fig:fig1 a, which in latex translates to \ref{fig:fig1} a. In my opinion, figure 1a looks much cleaner than figure 1 a.

Is there an easy way to get rid of that space between } and a?

-- Jonathan Monthly Atmospheric CO₂: November 2017: 405.14, November 2016: 403.53

jkitchin commented 6 years ago

Alternatively, use [[ref:fig:fig1]]a.

suyashbire1 commented 6 years ago

Thank you for the quick responses.

@jkitchin Thank you very much! That works. Can the insertion of square brackets be automated with org-ref-helm-insert-ref-link? Sorry if this is trivial, I am a new to emacs-lisp.

@jagrg Thank you for the solution. But I am not using the subfigure environment. My figures already have panels. I should have been clearer with my question.

jkitchin commented 6 years ago

You can set org-ref-prefer-bracket-links to t, and then all links will be bracketed. It isn't fine-tunable though, so it is all or nothing. There isn't a way to fine-tune the insert command much either, we already use prefix args for something else there I think.

suyashbire1 commented 6 years ago

(setq org-ref-prefer-bracket-links t) did not work. It still inserts links without brackets.

jkitchin commented 6 years ago

Sure enough, it looks like that is mostly for cite links. Sorry for the red herring!

suyashbire1 commented 6 years ago

I am using a snippet to achieve this (see yasnippet).

With the following snippet typing irl followed by a Tab does the trick.

# -*- mode: snippet -*-
# name: insert_ref_link
# key: irl
# --
[[`(org-ref-helm-insert-ref-link)`]]$0

Please feel free to close this issue if you don't plan to implement this feature in org-ref.

jkitchin commented 6 years ago

I will leave it open for now. There should probably be consistency across the links, but it might take while to get that.