如何去除 pandoc 引用周围的括号?

这是我在 LaTeX 中进行引用的方法

\documentclass[11pt]{article}

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

\begin{document}
... 灾难性的人口下降 (\cite{McIntyre__2015}).
\end{document}

我使用 pandoc 将其转换为 docxodt,这样我就可以从同事那里获取跟踪变化。

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

但是... 在生成的文档中,pandoc 自动在每个 \cite 调用周围添加了一个额外的括号。

...灾难性的人口下降 ((McIntyre 等人,2015)).

我真的很喜欢手动加括号... 有办法让 pandoc 停止添加这些额外的引用括号吗?

我有这样的印象,这可以在 pandoc 中使用 lua 过滤器完成... 我希望有人能告诉我如何解决这个问题的方向。

原文链接 https://stackoverflow.com/questions/69921491

点赞
stackoverflow用户2425163
stackoverflow用户2425163

可以使用 Lua 过滤器来修改引用模式,以此从引用中省略括号:

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

确保过滤器在 citeproc 之前运行,也就是在 pandoc 调用中该过滤器必须首先出现:

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

另一个选择是将 \cite 改为 \citet

2021-11-12 07:43:17
stackoverflow用户2849019
stackoverflow用户2849019

tarleb 的回答没有解决问题,但是他引导我找到了正确的文档

现在我明白 pandoc 依赖于 CSL 来实际格式化引用,而 lua 过滤器可以修改使用的引用类型(在文本中显示作者,还是在括号中显示作者)。

<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>

在我的 CSL 文档中,我只需从 <citation> <layout> 节点的 prefixsuffix 属性中删除括号即可。现在编译后的文档中只有我手动放置的括号出现。

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

2021-11-12 15:48:53