简体   繁体   English

AUCTeX:插入引用/引用而不包含宏

[英]AUCTeX: insert reference / citation without macro

Is there a way to add a reference / citation format which inserts the reference / citation label directly into the buffer without enclosing it into a macro? 有没有一种添加引用/引用格式的方法,该格式可以将引用/引用标签直接插入到缓冲区中而不将其包含在宏中?

To be clear: When I hit Cc ) AUCTeX prompts for a reference format, when I hit return it'll insert ~\\ref{LABEL} into the buffer [after selecting the appropriate reference in the next buffer]. 需要明确的是:当我点击Cc ) AUCTeX会提示您输入参考格式,当我点击return它将在缓冲区中插入~\\ref{LABEL} [在下一个缓冲区中选择适当的参考之后]。 I would like to add a reference format which is bound to \\?s (space) that inserts only the LABEL part. 我想添加绑定到\\?s (空格)的参考格式,该格式仅插入LABEL部分。

That is to say: I hit Cc ) , then <space> , then select the reference and... tadaa there's LABEL in the buffer. 那就是说:我按Cc ) ,然后<space> ,然后选择引用,然后... tadaa缓冲区中有LABEL

[Edit:] I have tried [编辑:]我已经尝试过

(eval-after-load "latex"
       '(progn
          (add-to-list
                'reftex-ref-style-alist
                '("Default" t
                  (("" ?\s))))))

however this encloses the label in curly braces and prepends ~ if there's a word before point. 但是,这会将标签用大括号括起来,并在点之前加一个~

I have created a solution by adding an around-advice to reftex-reference , however, it's not a pretty solution. 我通过在reftex-reference添加around-advice创建了一个解决方案,但是,这不是一个很好的解决方案。 I'll put it up as an answer but I'm still hoping for a better solution. 我将其作为答案,但我仍然希望有一个更好的解决方案。

(eval-after-load "latex"
  '(progn
     (add-to-list
      'reftex-ref-style-alist
      '("Default" t
    (("LABEL ONLY" ?\s))))

     (defadvice reftex-format-special (around reftex-format-special-labely-only activate)
       "Advice `reftex-format-special' such that if
REFSTYLE is \"LABEL ONLY\" it will insert
only the reference's label."
       (if (string= (ad-get-arg 2) "LABEL ONLY")
       (setq ad-return-value (format "%s" (ad-get-arg 0)))
     ad-do-it))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM