Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuring the ref command #463

Closed
drghirlanda opened this issue Jun 20, 2017 · 7 comments
Closed

configuring the ref command #463

drghirlanda opened this issue Jun 20, 2017 · 7 comments

Comments

@drghirlanda
Copy link

Hi,
I have two small configuration questions:

  1. I would like to use cleveref for LaTeX export, is there a way of changing \ref to \cref by configuring an org-ref variable?

  2. My lisp is very poor, how do I bind the org-ref insert ref and insert label commands to keys?

@jkitchin
Copy link
Owner

  1. It doesn't currently look possible to change that by a variable. You can however change how a ref link is exported. For latex only, and assuming all refs are crefs:
(org-link-set-parameters "ref" :export
			 (lambda (label desc format)
			   (format "\\cref{%s}" label)))

This seems like something that should be customizable, but it will take some work to do. So leave this issue open :)

  1. C-u C-c ] should insert a ref link
    C-u C-u C-c ] should insert a label link.

You can define another key, eg to use f7 and f8:

#+BEGIN_SRC emacs-lisp
(define-key org-mode-map (kbd "") org-ref-insert-ref-function)
(define-key org-mode-map (kbd "") org-ref-insert-label-function)
#+END_SRC

@drghirlanda
Copy link
Author

They all work, thanks a lot!

jkitchin added a commit that referenced this issue Jun 20, 2017
This allows you to set a default ref type and adds cref types. The manual was updated.
@jkitchin
Copy link
Owner

I think it is possible to customize this now. The variable org-ref-default-ref-type now controls the default type, and I added cref and Cref links as ref types.

@drghirlanda
Copy link
Author

That's great thanks! I will try once I get the chance to update org-ref

@drghirlanda
Copy link
Author

I can confirm that they both work: cref and Cref are at the bottom of the ref type list, and I can (setq org-ref-default-type "cref") to get cref: links without going through the list. Thank you very, very much!

@stefan2904
Copy link

In #463 (comment):

For latex only

stupid question, how does one restrict this override to latex exports? since otherwise this destroys exports to other formats ...

thanks!

@jkitchin
Copy link
Owner

you could try something like:

(org-link-set-parameters "ref" :export
(lambda (label desc format)
(cond ((eq 'latex format)
(format "\cref{%s}" label))
(t
(some-other-export-function)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants