andras-simonyi / citeproc-el

A CSL 1.0.2 Citation Processor for Emacs.
GNU General Public License v3.0
85 stars 9 forks source link

LaTeX citation styling. #34

Closed tecosaur closed 3 years ago

tecosaur commented 3 years ago

Hello,

I thought it would be nice to give CSL-generated LaTeX citations the same look as those generated by biblatex et. al. I asked the hyperref folks if it would be possible to apply the same styling, and they got back to me :slightly_smiling_face: (see https://github.com/latex3/hyperref/issues/197).

So, the following should accomplish this:

\documentclass{article}
\usepackage{xcolor}
\usepackage{hyperref}
\hypersetup{colorlinks}

\makeatletter
\newcommand{\citeprocitem}[2]{\hyper@linkstart{cite}{#1}#2\hyper@linkend}
\makeatother

\begin{document}

\citeprocitem{citeproc_bib_item_foo}{foo}

\hypertarget{citeproc_bib_item_foo}{Foo, the journal of Foo...}

\end{document}

Though I'd also be tempted to shorten things like so:

\newcommand{\citeprocitem}[2]{\hyper@linkstart{cite}{citeproc_bib_item_#1}#2\hyper@linkend}

Thoughts?

bdarcus commented 3 years ago

+1 in general on improving default output.

Related to #24 also.

andras-simonyi commented 3 years ago

Thanks for raising this and for the suggested solution! As an experiment I've implemented it in the branch 34-LaTeX_cite_link_styling. The reason I didn't use the more elegant custom-command based solution(s) you suggested is that citeproc-el in itself cannot touch the LaTeX preamble, so using something like \citeprocitem would break the current Org CSL export processor. In contrast, this could be merged immediately without any problems AFAICS. Of course, later we can try to switch citeproc-el and oc-csl simultaneously to the less verbose solution. WDYT?

tecosaur commented 3 years ago

Great :slightly_smiling_face:. Regarding the somewhat verbose solution currently used, perhaps we could extend org-cite-csl-finalizer in oc-csl to add a bit more to the preamble and make this cleaner?

andras-simonyi commented 3 years ago

. Regarding the somewhat verbose solution currently used, perhaps we could extend org-cite-csl-finalizer in oc-csl to add a bit more to the preamble and make this cleaner?

Yes, that is what I meant by switching oc-csl. I've already accumulated a number of patches but want to send them only when my Emacs copyright assignment paperwork gets sorted out (it's in progress). Until then feel free to propose this patch against oc-csl.eland I can adapt citeproc-el whenever it's convenient.

tecosaur commented 3 years ago

I'll probably make a patch / PR or two then :slightly_smiling_face:

andras-simonyi commented 3 years ago

Perfect, thanks in advance!

andras-simonyi commented 3 years ago

A short update on this: it turns out that \makeatletter and \makeatother don't work inside footnotes (among others), so the only way forward is to define a special command in the preamble as you recommended -- my verbose suggestion would break LaTeX export for all footnote styles.

tecosaur commented 3 years ago

I've finally got around to making that patch: https://lists.gnu.org/archive/html/emacs-orgmode/2021-08/msg00354.html

tecosaur commented 3 years ago

Pushed: https://code.orgmode.org/bzg/org-mode/commit/818bec57eb97fd9f65cf380f32a2639d9647ed3d :slightly_smiling_face:

andras-simonyi commented 3 years ago

Thanks! I've just merged the corresponding change here -- closing the issue.