Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible citation enhancement #8269

Open
jgm opened this issue Sep 1, 2022 · 5 comments
Open

Possible citation enhancement #8269

jgm opened this issue Sep 1, 2022 · 5 comments

Comments

@jgm
Copy link
Owner

jgm commented Sep 1, 2022

This would require changes in both pandoc and citeproc, but the idea would be that you can

Blah blah [@smith2000, p. 33].  More stuff from Smith [@ p. 44].

and the second citation would be treated as locator-only citation to smith2000 (or whatever the last citation was). I find that in my own writing I am often commenting extensively on one source, with different page references. It's currently awkward to do that with pandoc; you need to either (a) type the locator manually or (b) use a full citation. Drawback of (a) is that you have to match the locator formatting of the style (and you're in trouble if you change styles); in addition, this can affect ibid and such things. Drawback of (b) is that you get overly verbose and repetitive formatted citations.

The proposal would be that a citation with just @ followed by space is parsed as a locator-only citation to the last cited item.

Comments welcome. @tarleb @njbart @denismaier @bdarcus

@jgm jgm added the enhancement label Sep 1, 2022
@denismaier
Copy link
Contributor

denismaier commented Sep 1, 2022

I very much like the idea to add more citation modes.

In that particular case, though, I'm unsure that would be the best solution for the given problem. Shouldn't this be handled by the style? (I know that Chicago, MLA and APA don't deal with this, but that could be changed.) If users had to use different modes for this, that would make switching between in-text and note styles more difficult. (What will happen to such a locator only citation when it ends up in a note?) Also reordering sentences might become awkward and may require adjusting citations, which goes a bit against the whole point of automated citations.

That said, I agree a mode for locator only citations would be nice. I'd even say a generic mechanism for additional citation modes would be great. Maybe something like the new syntax in org, even though that goes against the markdown philosophy...

@jgm
Copy link
Owner Author

jgm commented Sep 1, 2022

If users had to use different modes for this, that would make switching between in-text and note styles more difficult.

Good point. It does seem like this is something that could be handled by the style, in priniciple. (Are there any author-date styles that do, though? Is it even possible given CSL?)

If styles did handle this, the [@ p. 33] syntax could still be introduced as a shorthand for a regular citation.

@denismaier
Copy link
Contributor

denismaier commented Sep 2, 2022

Yes, adding [@ p. 33] could be a nice shorthand and useful for easier input. (Though with proper editor suppor this should probably not be necessary.)

Regarding CSL: this style basically does that.

With this input:

---
title: Test
references:
- type: article-journal
  id: WatsonCrick1953
  author:
  - family: Watson
    given: J. D.
  - family: Crick
    given: F. H. C.
  issued:
    date-parts:
    - - 1953
      - 4
      - 25
  title: 'Molecular structure of nucleic acids: a structure for
    deoxyribose nucleic acid'
  title-short: Molecular structure of nucleic acids
  container-title: Nature
  volume: 171
  issue: 4356
  page: 737-738
  DOI: 10.1038/171737a0
  URL: https://www.nature.com/articles/171737a0
  language: en-GB
- type: book
  id: doe
  author:
  - family: Doe
    given: John
  title: A book
  issued:
    date-parts:
    - - 2022
...

This is a test.
[@WatsonCrick1953, p.34] argue this and that.
And there is much more that we need to quote [@WatsonCrick1953, 44].
And another citation [@WatsonCrick1953, 55]
Then, there's something from Doe [@doe, 66].
Something else from Doe [@doe, 77]
Again, back to the first reference [@WatsonCrick1953, 88]

Result:

grafik

The problem is that many style guides restrict this kind of behaviour to citations that occur within a single paragraph, e.g. MLA, sec. 6.45, https://mlahandbookplus.org/books/book/5/chapter/58113/Quoting-and-Paraphrasing-Sources; CMoS, sec. 15.27, https://www.chicagomanualofstyle.org/book/ed17/part3/ch15/psec027.html. APA on the other hand does not endorse this behaviour at all, sec. 8.16: "If you need to repeat a citation ... repeat the entire citation; do not, for example, include only a page number".

So, even for the styles that encourage locator only citations, you'll need a way to "reset" the ibid-tracking, i.e., to force a regular citation at certain points. (In this case after every new paragraph, but this could also be nice as a general mechanism after certain headings. Even more, at some points you might want to have full citation again, but that's a different issue.)

This is not possible within CSL itself---mainly because that wouldn't work for tools like MS Word. And I think that's also the reason why most styles in the official repo don't do that. So, the idea is that you either type the locator only citations yourself, or use a full citation each time, like you've stated above.

But, in pandoc it should be possible to deal with this in a more elegant way. I've used a simple filter hack with pandoc-citeproc that can be used here as well. This filter removes certain citations from the AST, with the effect that "ibid." is suppressed for the next citation. With another filter it should be possible to insert these fake citations at the beginning of each paragraph, process the citations with citeproc, and then remove the fake citations again. Hacky, but that should get us somewhere already.

Of course, a native solution to control position tracking would be even better. Something like:

csl-position-control:
  ibid-reset:
  - paragraph
  subsequent-reset:
  - header, 1

What do you think?

@denismaier
Copy link
Contributor

denismaier commented Sep 3, 2022

Ok, first try.

Use these filters:

  1. restrict-ibid.lua
function Para (el)
  table.insert(el.content, 1, pandoc.Cite({pandoc.Str('Whatever')}, {pandoc.Citation('mancite', 'NormalCitation')}))
  return el
end
  1. mancite.lua
function Cite (cite)
  if cite.citations[1].id == 'mancite' then
    return {}
  end
end

Testfile:

---
title: Test
references:
- type: article-journal
  id: WatsonCrick1953
  author:
  - family: Watson
    given: J. D.
  - family: Crick
    given: F. H. C.
  issued:
    date-parts:
    - - 1953
      - 4
      - 25
  title: 'Molecular structure of nucleic acids: a structure for
    deoxyribose nucleic acid'
  title-short: Molecular structure of nucleic acids
  container-title: Nature
  volume: 171
  issue: 4356
  page: 737-738
  DOI: 10.1038/171737a0
  URL: https://www.nature.com/articles/171737a0
  language: en-GB
- type: book
  id: doe
  author:
  - family: Doe
    given: John
  title: A book
  issued:
    date-parts:
    - - 2022
...

This is a test.
[@WatsonCrick1953, p.34] argue this and that.
And there is much more that we need to quote [@WatsonCrick1953, 44].
And another citation [@WatsonCrick1953, 55]
Then, there's something from Doe [@doe, 66].
Something else from Doe [@doe, 77]
Again, back to the first reference [@WatsonCrick1953, 88].

The next paragraph starts with the same reference, but we want a regular citation [@WatsonCrick1953, 99].

Command line:

pandoc locs.txt -o test.html -L restrict-ibid.lua --citeproc -L mancite.lua --standalone --csl=chicago-author-date-ibid-only-loc.csl

Result:

grafik

So, that basically works, but it's of course not ideal. We'll probably want the same behaviour for other elements as well. I've tried an equivalent filter for Inlines but that did not work, because that inserted the mancite into other citation as well...

function Inlines(inlines)
  table.insert(inlines, 1, pandoc.Cite({pandoc.Str('Whatever')}, {pandoc.Citation('mancite', 'NormalCitation')}))
  return inlines
end

But maybe there is a way to make this work? Maybe just add the fake citation to every block?

Update: Like so:

function Pandoc(doc)
    for i,el in pairs(doc.blocks) do
	   table.insert(el.content, 1, pandoc.Cite({pandoc.Str('Whatever')}, {pandoc.Citation('mancite', 'NormalCitation')}))
    end
    return pandoc.Pandoc(doc.blocks, doc.meta)
end

I still need to test this a bit more, but maybe @jgm or @tarleb know whether this approach might have any drawbacks? (By the way, I've used the blocks processing example from the homepage, but why does that use pairs instead of ipairs. Both seem to work...)

@denismaier
Copy link
Contributor

Any further thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants