citation-style-language / styles

Official repository for Citation Style Language (CSL) citation styles.
https://citationstyles.org/
3.25k stars 3.74k forks source link

APA CSL uses an "&" rather than an "and" for in-text citations #3748

Open samueldodson opened 5 years ago

samueldodson commented 5 years ago

The APA CSL uses an "&" rather than an "and" for in-text citations. For example, "Foo & Bar (1999)" rather than "Foo and Bar (1999)". Is there a way to use "and" (or, similarly, "et", "und", "y", etc.) rather than "&"? I am using the latest version of the APA CSL with pandoc (2.3.1) and pandoc-citeproc (0.14.5). Here is an example:

Input (input.md):

---
references:

- id: foo1999
  title: A title
  author:
  - family: Foo
  - family: Bar
  type: manuscript
  issued:
    year: 1999
---

@foo1999

Output (pandoc -f markdown -t plain input.md --csl apa.csl --filter pandoc-citeproc):

Foo & Bar (1999)

Thanks.

rmzelle commented 5 years ago

This requires a modified APA citation style. Changing all instances of and="symbol" with and="text" should do the trick. See the entry for "and" at http://docs.citationstyles.org/en/stable/specification.html#name.

adam3smith commented 5 years ago

Note that & is correct for standard APA citations (Smith & Meyer, 1981). CSL doesn't allow to specify out-of-parentheses citations with a different format as APA prescribes.

samueldodson commented 5 years ago

Thanks, @rmzelle and @adam3smith. It is too bad CSL does not allow for independent parenthetical and non-parenthetical citation formatting. I will just use this Pandoc lua filter to replace "&" with "and" for non-parenthetical citations:

function Cite(elem)
    if elem.citations[1].mode == "AuthorInText" then
        elem.content = pandoc.walk_inline(elem, {
            Str = function(el)
                return pandoc.Str(string.gsub(el.text, "&", "and"))
            end})
    end
    return pandoc.Cite(elem.content, elem.citations, elem.tag)
end
frastlin commented 5 years ago

Note that to use this filter with Pandoc, this filter needs to be saved to a file, probably in the current directory (Below it is apa_and.lua) and the filter needs to come after citeproc like:

pandoc --filter pandoc-citeproc --lua-filter=apa_and.lua Input.md -s -o Output.docx
dwbatten commented 7 months ago

I am currently working with this issue in Quarto, and I am having trouble getting it to work. I've followed the Quarto instructions to set up a filter, and it runs but doesn't make the prescribed changes. I'm not knowledgeable of this syntax, so I was wondering if anyone's worked with this more recently and/or in Quarto?

wjschne commented 5 months ago

@dwbatten,

I adapted @samueldodson's code for apaquarto, a Quarto extension for APA manuscripts. I added support for other languages (e.g., "and" becomes "y" in Spanish). I also added the ability to make "possessive citations." For example, @schneider2024 ['s] argument is that ... becomes "Schneider's (2024) argument is that ..." The filter is here.

bwiernik commented 5 months ago

Note that CSL 1.1/2.0 will support separate narrative citation forms. The above solution is great for users of pandoc in the mean time.