public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Backward citations hyperlinks with pandoc ?
@ 2022-01-26 20:22 Cassandra Lyderitz
  2022-01-26 20:46 ` John MacFarlane
  2022-01-29 18:55 ` John MacFarlane
  0 siblings, 2 replies; 7+ messages in thread
From: Cassandra Lyderitz @ 2022-01-26 20:22 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

Hello!

I wonder whether there is a possibility to add backward references from
bibliography onto inline citations in PDF (first and foremost, leave out
other formats) generated with pandoc or with any of its extensions.

The pandoc user guide shows no sign of such possibility. I know this is
possible if I set natbib and biblatex as my citations processor, but LaTeX
is more prone to errors and it lacks so many useful citation styles and to
the best of my knowledge, there is no such tool to convert .csl files to
packages and/or .bst or any other relevant files, so the decision to change
the citation processor is not easy, and so I'm asking this questions.

Thanks in advance for any response!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAGvXcu_pFVjBVoTm8NGgvG2y-Q0B-h-PRNOoW-PhcYD6thMW%3DA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 1511 bytes --]

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

* Re: Backward citations hyperlinks with pandoc ?
  2022-01-26 20:22 Backward citations hyperlinks with pandoc ? Cassandra Lyderitz
@ 2022-01-26 20:46 ` John MacFarlane
  2022-01-29 18:55 ` John MacFarlane
  1 sibling, 0 replies; 7+ messages in thread
From: John MacFarlane @ 2022-01-26 20:46 UTC (permalink / raw)
  To: Cassandra Lyderitz, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


This is something you could probably add with a filter.
But what would the backlinks look like?  (Keeping in
mind that there may be multiple citations to the same item.)

Cassandra Lyderitz <cassandra.lyderitz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hello!
>
> I wonder whether there is a possibility to add backward references from
> bibliography onto inline citations in PDF (first and foremost, leave out
> other formats) generated with pandoc or with any of its extensions.
>
> The pandoc user guide shows no sign of such possibility. I know this is
> possible if I set natbib and biblatex as my citations processor, but LaTeX
> is more prone to errors and it lacks so many useful citation styles and to
> the best of my knowledge, there is no such tool to convert .csl files to
> packages and/or .bst or any other relevant files, so the decision to change
> the citation processor is not easy, and so I'm asking this questions.
>
> Thanks in advance for any response!
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAGvXcu_pFVjBVoTm8NGgvG2y-Q0B-h-PRNOoW-PhcYD6thMW%3DA%40mail.gmail.com.


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

* Re: Backward citations hyperlinks with pandoc ?
  2022-01-26 20:22 Backward citations hyperlinks with pandoc ? Cassandra Lyderitz
  2022-01-26 20:46 ` John MacFarlane
@ 2022-01-29 18:55 ` John MacFarlane
       [not found]   ` <m27dail6cs.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: John MacFarlane @ 2022-01-29 18:55 UTC (permalink / raw)
  To: Cassandra Lyderitz, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


I've come up with a filter that does this.  For LaTeX/PDF output,
it will have links to page numbers; otherwise unique numerical
links will be used.

backlinks.lua

```
-- lua filter to add backlinks to citations
-- run after --citeproc on the command line

-- cites is a table mapping citation item identifiers
-- to an array of cite identifiers
local cites = {}

-- counter for cite identifiers
local cite_number = 1

local function with_latex_label(s, el)
  if FORMAT == "latex" then
    return {pandoc.RawInline("latex", "\\label{" .. s .. "}"), el}
  else
    return {el}
  end
end

function Cite(el)
  local cite_id = "cite_" .. cite_number
  cite_number = cite_number + 1
  for _,citation in ipairs(el.citations) do
    if cites[citation.id] then
      table.insert(cites[citation.id], cite_id)
    else
      cites[citation.id] = {cite_id}
    end
  end
  return pandoc.Span(with_latex_label(cite_id, el), pandoc.Attr(cite_id))
end

function Div(el)
  local citation_id = el.identifier:match("ref%-(.+)")
  if citation_id then
    local backlinks = {pandoc.Str("Cited:"),pandoc.Space()}
    for i,cite_id in ipairs(cites[citation_id]) do
      local marker = pandoc.Str(i)
      if FORMAT == "latex" then
        marker = pandoc.RawInline("latex", "\\pageref{" .. cite_id .. "}")
      end
      if #backlinks > 2 then
        table.insert(backlinks, pandoc.Str(","))
        table.insert(backlinks, pandoc.Space())
      end
      table.insert(backlinks, pandoc.Link(marker, "#"..cite_id))
    end
    table.insert(el.content, pandoc.Para({pandoc.Span(backlinks,
                                          pandoc.Attr("",{"csl-indent"}))}))
    return el
  end
end

```

Cassandra Lyderitz <cassandra.lyderitz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hello!
>
> I wonder whether there is a possibility to add backward references from
> bibliography onto inline citations in PDF (first and foremost, leave out
> other formats) generated with pandoc or with any of its extensions.
>
> The pandoc user guide shows no sign of such possibility. I know this is
> possible if I set natbib and biblatex as my citations processor, but LaTeX
> is more prone to errors and it lacks so many useful citation styles and to
> the best of my knowledge, there is no such tool to convert .csl files to
> packages and/or .bst or any other relevant files, so the decision to change
> the citation processor is not easy, and so I'm asking this questions.
>
> Thanks in advance for any response!
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAGvXcu_pFVjBVoTm8NGgvG2y-Q0B-h-PRNOoW-PhcYD6thMW%3DA%40mail.gmail.com.


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

* Re: Backward citations hyperlinks with pandoc ?
       [not found]   ` <m27dail6cs.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
@ 2022-07-26  4:21     ` Adriano Rutz
  2022-08-04 15:33     ` Albert Krewinkel
  1 sibling, 0 replies; 7+ messages in thread
From: Adriano Rutz @ 2022-07-26  4:21 UTC (permalink / raw)
  To: pandoc-discuss


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

Looks very good! Is there a solution to have it *inline*? So that the table 
is inserted without linebreaks directly with the citation?

Le samedi 29 janvier 2022 à 19:55:31 UTC+1, John MacFarlane a écrit :

>
> I've come up with a filter that does this. For LaTeX/PDF output,
> it will have links to page numbers; otherwise unique numerical
> links will be used.
>
> backlinks.lua
>
> ```
> -- lua filter to add backlinks to citations
> -- run after --citeproc on the command line
>
> -- cites is a table mapping citation item identifiers
> -- to an array of cite identifiers
> local cites = {}
>
> -- counter for cite identifiers
> local cite_number = 1
>
> local function with_latex_label(s, el)
> if FORMAT == "latex" then
> return {pandoc.RawInline("latex", "\\label{" .. s .. "}"), el}
> else
> return {el}
> end
> end
>
> function Cite(el)
> local cite_id = "cite_" .. cite_number
> cite_number = cite_number + 1
> for _,citation in ipairs(el.citations) do
> if cites[citation.id] then
> table.insert(cites[citation.id], cite_id)
> else
> cites[citation.id] = {cite_id}
> end
> end
> return pandoc.Span(with_latex_label(cite_id, el), pandoc.Attr(cite_id))
> end
>
> function Div(el)
> local citation_id = el.identifier:match("ref%-(.+)")
> if citation_id then
> local backlinks = {pandoc.Str("Cited:"),pandoc.Space()}
> for i,cite_id in ipairs(cites[citation_id]) do
> local marker = pandoc.Str(i)
> if FORMAT == "latex" then
> marker = pandoc.RawInline("latex", "\\pageref{" .. cite_id .. "}")
> end
> if #backlinks > 2 then
> table.insert(backlinks, pandoc.Str(","))
> table.insert(backlinks, pandoc.Space())
> end
> table.insert(backlinks, pandoc.Link(marker, "#"..cite_id))
> end
> table.insert(el.content, pandoc.Para({pandoc.Span(backlinks,
> pandoc.Attr("",{"csl-indent"}))}))
> return el
> end
> end
>
> ```
>
> Cassandra Lyderitz <cassandra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
> > Hello!
> >
> > I wonder whether there is a possibility to add backward references from
> > bibliography onto inline citations in PDF (first and foremost, leave out
> > other formats) generated with pandoc or with any of its extensions.
> >
> > The pandoc user guide shows no sign of such possibility. I know this is
> > possible if I set natbib and biblatex as my citations processor, but 
> LaTeX
> > is more prone to errors and it lacks so many useful citation styles and 
> to
> > the best of my knowledge, there is no such tool to convert .csl files to
> > packages and/or .bst or any other relevant files, so the decision to 
> change
> > the citation processor is not easy, and so I'm asking this questions.
> >
> > Thanks in advance for any response!
> >
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "pandoc-discuss" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to pandoc-discus...-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/CAGvXcu_pFVjBVoTm8NGgvG2y-Q0B-h-PRNOoW-PhcYD6thMW%3DA%40mail.gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/060768c9-ad48-4508-a567-12fa4d8ba353n%40googlegroups.com.

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

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

* Re: Backward citations hyperlinks with pandoc ?
       [not found]   ` <m27dail6cs.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
  2022-07-26  4:21     ` Adriano Rutz
@ 2022-08-04 15:33     ` Albert Krewinkel
       [not found]       ` <87wnboja0y.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Albert Krewinkel @ 2022-08-04 15:33 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> I've come up with a filter that does this.  For LaTeX/PDF output,
> it will have links to page numbers; otherwise unique numerical
> links will be used.

I'd like to publish this on GitHub. John, is it ok if I publish it under
the MIT or BSD-3 license?

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

* Re: Backward citations hyperlinks with pandoc ?
       [not found]       ` <87wnboja0y.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
@ 2022-08-04 16:26         ` John MacFarlane
       [not found]           ` <BB7AC9AA-681D-4310-879B-D7AF7F4E16F6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: John MacFarlane @ 2022-08-04 16:26 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw



> On Aug 4, 2022, at 8:33 AM, Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> wrote:
> 
> 
> John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
> 
>> I've come up with a filter that does this.  For LaTeX/PDF output,
>> it will have links to page numbers; otherwise unique numerical
>> links will be used.
> 
> I'd like to publish this on GitHub. John, is it ok if I publish it under
> the MIT or BSD-3 license?
> 


Fine with me!


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

* Re: Backward citations hyperlinks with pandoc ?
       [not found]           ` <BB7AC9AA-681D-4310-879B-D7AF7F4E16F6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2022-08-10  7:57             ` Albert Krewinkel
  0 siblings, 0 replies; 7+ messages in thread
From: Albert Krewinkel @ 2022-08-10  7:57 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


John MacFarlane <fiddlosopher-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

>> On Aug 4, 2022, at 8:33 AM, Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
>> wrote:
>>
>> John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:
>>
>>> I've come up with a filter that does this.  For LaTeX/PDF output,
>>> it will have links to page numbers; otherwise unique numerical
>>> links will be used.
>>
>> I'd like to publish this on GitHub. John, is it ok if I publish it under
>> the MIT or BSD-3 license?
>
> Fine with me!

Thanks! I've created a repo for it here:
<https://github.com/tarleb/citation-backlinks>

Website (generated with my experimental Lua filter template):
<https://tarleb.com/citation-backlinks>

-- 
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


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

end of thread, other threads:[~2022-08-10  7:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 20:22 Backward citations hyperlinks with pandoc ? Cassandra Lyderitz
2022-01-26 20:46 ` John MacFarlane
2022-01-29 18:55 ` John MacFarlane
     [not found]   ` <m27dail6cs.fsf-jF64zX8BO0+FqBokazbCQ6OPv3vYUT2dxr7GGTnW70NeoWH0uzbU5w@public.gmane.org>
2022-07-26  4:21     ` Adriano Rutz
2022-08-04 15:33     ` Albert Krewinkel
     [not found]       ` <87wnboja0y.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-08-04 16:26         ` John MacFarlane
     [not found]           ` <BB7AC9AA-681D-4310-879B-D7AF7F4E16F6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2022-08-10  7:57             ` Albert Krewinkel

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 NNTP newsgroup(s).