【问题标题】:How to remove parentheses around pandoc citations?如何删除 pandoc 引用周围的括号?
【发布时间】:2021-11-10 23:36:59
【问题描述】:

这是我在 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}

我正在使用 pandoc 将其转换为 docxodt,以便我可以从同事那里获得跟踪更改。

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

但是...在生成的文档中,pandoc 会自动将每个 \cite 调用用一组额外的括号括起来。

...灾难性的人口减少((McIntyre et al. 2015))。

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

我的印象是,这可以通过 pandoc 中的 lua 过滤器来完成......我希望有人能给我一些关于如何解决这个问题的正确方向的指示。

【问题讨论】:

    标签: lua latex pandoc


    【解决方案1】:

    可以使用 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

    【讨论】:

    • 谢谢!但是,它仅将作者从括号中删除,同时仍将它们留在年份。从这个答案中,我刚刚意识到 lua 过滤器并不是真正的正确方法。
    【解决方案2】:

    tarleb 的回答并没有解决问题,但它确实将我带到了right documentation

    我现在明白 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 文档中,我刚刚从 &lt;citation&gt; &lt;layout&gt; 节点的 prefixsuffix 属性中删除了括号。 现在只有我手动放置的括号出现在编译的文档中。

    ...灾难性的人口减少(McIntyre 等人,2015 年)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2020-05-28
      • 2019-03-01
      • 2011-04-19
      • 2021-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多