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.
This commit is contained in:
TEC 2021-08-23 18:14:05 +08:00
parent 3664447eb2
commit 818bec57eb
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 2 additions and 0 deletions

View File

@ -589,6 +589,8 @@ property list."
(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}")))