emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-cite: define \citeprocitem for LaTeX export
@ 2021-08-23 10:23 Timothy
  2021-08-26  8:18 ` Timothy
  0 siblings, 1 reply; 3+ messages in thread
From: Timothy @ 2021-08-23 10:23 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 528 bytes --]

Hi All,

There’s been a discussion over at citeproc-el about how to make hyperref treat
its references the same way as bib(la)tex references, and to get this to work we
need to add a command definition to the preamble, `\citeprocitem'.

┌────
│ \makeatletter
│ \newcommand{\citeprocitem}[2]{\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\hyper@linkend}
│ \makeatother
└────

See <https://github.com/andras-simonyi/citeproc-el/issues/34> for more information.

All the best,
*Timothy*

[-- Attachment #1.2: Type: text/html, Size: 4006 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-oc-csl-Define-citeprocitem-for-LaTeX-export.patch --]
[-- Type: text/x-patch, Size: 1409 bytes --]

From 0988d1c331b8872a4c4aa1b1ea40aa2f9f668d17 Mon Sep 17 00:00:00 2001
From: TEC <tec@tecosaur.com>
Date: Mon, 23 Aug 2021 18:14:05 +0800
Subject: [PATCH 3/4] oc-csl: Define \citeprocitem for LaTeX export

* lisp/oc-csl.el (org-cite-csl-finalizer): In order for
citeproc-generated references to be treated the same as bib(la)tex
references by hyperref, we need to make use of \hyper@linkstart.
However, this requires \makeatletter and \makeatother, which can only be
used in the preamble.  To allow citeproc-el to use \hyper@linkstart, we
add a command definition in the preamble, \citeprocitem.
---
 lisp/oc-csl.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index 0a057036e..617bddb7e 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -589,6 +589,8 @@ (defun org-cite-csl-finalizer (output _keys _files _style _backend info)
     (with-temp-buffer
       (save-excursion (insert output))
       (when (search-forward "\\begin{document}" nil t)
+        ;; Ensure that \citeprocitem is defined for citeproc-el
+        (insert "\\makeatletter\n\\newcommand{\\citeprocitem}[2]{\\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\\hyper@linkend}\n\\makeatother\n\n")
         ;; Ensure there is a \usepackage{hanging} somewhere or add one.
         (goto-char (match-beginning 0))
         (let ((re (rx "\\usepackage" (opt "[" (*? nonl) "]") "{hanging}")))
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-19 13:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-23 10:23 [PATCH] org-cite: define \citeprocitem for LaTeX export Timothy
2021-08-26  8:18 ` Timothy
2021-09-19 13:19   ` Timothy

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).