user2849019
user2849019

Reputation:

How to remove parentheses around pandoc citations?

Here's how I do my citations in latex

\documentclass[11pt]{article}

\usepackage[
    backend=biber, style=apa, 
    giveninits=true, uniquename=init,
    citestyle=authoryear]{biblatex}
\bibliography{references.bib} 

\begin{document}
... catastrophic population declines (\cite{McIntyre__2015}).
\end{document}

I'm using pandoc to convert this to docx or odt so I can get track changes from colleagues.

pandoc ./main.tex -f latex -t odt --bibliography=./references.bib --csl ../apa.csl -o output.odt

However... in the resulting document, pandoc automatically surrounds every \cite call with an extra set of parenthesis.

...catastrophic population declines ((McIntyre et al. 2015)).

I really like doing parentheses manually... is there a way for me to get pandoc to stop adding these extra citation parentheses?

I have the impression that this can be done with lua filters in pandoc... I was hoping someone could give me some pointers in the right direction on how to address this.

Upvotes: 2

Views: 862

Answers (2)

user2849019
user2849019

Reputation:

The answer from tarleb didn't solve the question, but it did lead me to the right documentation.

I now understand that pandoc relies on CSL for the actual formatting of citations, while lua filters can modify what kind of citation is used (author in text, vs author in parenthesis).

<citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true" disambiguate-add-givenname="true" collapse="year" givenname-disambiguation-rule="primary-name-with-initials">
    <layout prefix="" suffix="" delimiter="; ">
    </layout>
  </citation>

In my CSL doc, I just removed the parentheses from the prefix and suffix attributes of the <citation> <layout> node. Now only my manually placed parentheses appear in the compiled doc.

...catastrophic population declines (McIntyre et al., 2015).

Upvotes: 2

tarleb
tarleb

Reputation: 22599

A Lua filter could be used to change the citation mode such that the parens are omitted:

function Cite(cite)
  for _, c in ipairs(cite.citations) do
    c.mode = pandoc.AuthorInText
  end
  return cite
end

Make sure that the filter runs before citeproc, i.e., it must occur first in the call to pandoc:

pandoc --lua-filter=modify-citations.lua --citeproc ...

The alternative would be to change \cite into \citet.

Upvotes: 1

Related Questions