r markdown biblio-style 不起作用 [英] r markdown biblio-style does not work

查看:24
本文介绍了r markdown biblio-style 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在更改论文中参考书目的引用风格时遇到了一些麻烦.根据r-markdown 指定围兜样式(我需要acm 来自 latex) 我只需要执行以下操作:

I have some troubles of changing the citation style of bibliography in my thesis. According to r-markdown to specify the bib style (I need acm from latex) I just need to do the following:

---
title: "title"
bibliography: biblioteka.bib
biblio-style: acm
output:
    pdf_document
---

但是,biblio-style:acm 似乎对引用风格没有影响.

However, the biblio-style: acm seems to have no influences on the citation style.

当前引用:

随机森林已经应用于信用评分[@author1] ...

random forest has been already applied in credit scoring [@author1] ...

@Article{author1,
   Title                   = {some title},
   Author                  = {Einstein},
   Year                    = {1997}
}

<小时>

想要的输出:

随机森林已经应用于信用评分[1] ...

random forest has been already applied in credit scoring [1] ...

References
[1] Einstein, some title, 1997

推荐答案

另一种最适合我的可能性是添加 Citation样式语言 (CSL) 文件 - 在您的情况下为 acm.csl - 并在 YAML 标头中引用它.打开您的文本编辑器并将以下 XML-Code 复制到其中,将其保存到您的工作目录并将其重命名为acm.csl".

Another possibility which works best for me is to add a Citation Style Language (CSL) file - in your case a acm.csl - and refer to it in the YAML header. Open your text editor and copy following XML-Code into it, save it into your working directory and rename it to "acm.csl".

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
  <info>
    <title>ACM SIGCHI Proceedings (2016)</title>
    <id>http://www.zotero.org/styles/acm-sigchi-proceedings</id>
    <link href="http://www.zotero.org/styles/acm-sigchi-proceedings" rel="self"/>
    <link href="http://cscw.acm.org/2016/submit/sigchi-word-proceedings.zip" rel="documentation"/>
    <author>
      <name>Yevgeniy Medynskiy</name>
      <email>eugenem@gatech.edu</email>
    </author>
    <contributor>
      <name>Sebastian Karcher</name>
    </contributor>
    <contributor>
      <name>Eric Baumer</name>
      <email>ebaumer@ics.uci.edu</email>
    </contributor>
    <contributor>
      <name>Svetlana Yarosh</name>
      <email>lana@cc.gatech.edu</email>
    </contributor>
    <contributor>
      <name>Lilly Irani</name>
      <email>lirani@ics.uci.edu</email>
    </contributor>
    <category citation-format="numeric"/>
    <category field="engineering"/>
    <updated>2012-09-27T22:06:38+00:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <macro name="author">
    <group suffix=".">
      <names variable="author">
        <name delimiter=", " and="text" sort-separator=", "/>
        <label form="short" prefix=" (" suffix=")"/>
        <substitute>
          <names variable="editor"/>
        </substitute>
      </names>
    </group>
  </macro>
  <macro name="editor">
    <names variable="editor">
      <name delimiter=", " and="text" delimiter-precedes-last="never"/>
      <label form="short" prefix=" (" suffix=")"/>
    </names>
  </macro>
  <macro name="title">
    <choose>
      <if type="bill book graphic legal_case legislation motion_picture report song" match="any">
        <text variable="title" font-style="italic"/>
      </if>
      <else>
        <text variable="title"/>
      </else>
    </choose>
  </macro>
  <macro name="year">
    <date variable="issued">
      <date-part name="year"/>
    </date>
  </macro>
  <macro name="journal">
    <group delimiter=", ">
      <group delimiter=" ">
        <text variable="container-title" font-style="italic"/>
        <text variable="volume"/>
      </group>
      <text variable="issue"/>
    </group>
  </macro>
  <macro name="edition">
    <choose>
      <if is-numeric="edition">
        <group delimiter=" ">
          <number variable="edition" form="ordinal"/>
          <text term="edition" form="short"/>
        </group>
      </if>
      <else>
        <text variable="edition"/>
      </else>
    </choose>
  </macro>
  <macro name="book-publisher">
    <group delimiter=", ">
      <text variable="publisher"/>
      <text variable="publisher-place"/>
    </group>
  </macro>
  <macro name="access">
    <choose>
      <if variable="DOI">
        <text variable="DOI" prefix="https://doi.org/"/>
      </if>
      <else-if variable="URL">
        <group delimiter=" ">
          <text term="retrieved" text-case="capitalize-first"/>
          <date variable="accessed" form="text"/>
          <text term="from"/>
          <text variable="URL"/>
        </group>
      </else-if>
    </choose>
  </macro>
  <citation collapse="citation-number">
    <sort>
      <key variable="citation-number"/>
    </sort>
    <layout prefix="[" suffix="]" delimiter=",">
      <group delimiter=":">
        <text variable="citation-number"/>
        <text variable="locator"/>
      </group>
    </layout>
  </citation>
  <bibliography second-field-align="flush" entry-spacing="0">
    <sort>
      <key macro="author"/>
      <key variable="issued"/>
    </sort>
    <layout>
      <text variable="citation-number" suffix="."/>
      <group delimiter=". " suffix=". ">
        <text macro="author"/>
        <text macro="year"/>
        <text macro="title"/>
      </group>
      <group suffix=".">
        <choose>
          <if type="bill book graphic legal_case legislation motion_picture report song thesis" match="any">
            <text macro="book-publisher" suffix="."/>
          </if>
          <else-if type="paper-conference">
            <group suffix="." delimiter=", ">
              <group delimiter=" ">
                <text term="in" text-case="capitalize-first"/>
                <group delimiter=" ">
                  <text variable="container-title" font-style="italic"/>
                  <text variable="collection-title" prefix="(" suffix=")"/>
                </group>
              </group>
              <text variable="page"/>
            </group>
          </else-if>
          <else-if type="chapter" match="any">
            <group delimiter=" ">
              <text term="in" text-case="capitalize-first"/>
              <group delimiter=", ">
                <group delimiter=" ">
                  <text variable="container-title" font-style="italic"/>
                  <text macro="edition" prefix="(" suffix=")"/>
                </group>
                <text macro="editor"/>
              </group>
            </group>
            <group suffix="." delimiter=", " prefix=". ">
              <text macro="book-publisher"/>
              <text variable="page"/>
            </group>
          </else-if>
          <else-if type="article-journal">
            <group suffix="." delimiter=": ">
              <text macro="journal"/>
              <text variable="page"/>
            </group>
          </else-if>
          <else>
            <group suffix="." delimiter=", ">
              <group delimiter=" " font-style="italic">
                <text variable="container-title"/>
                <text variable="volume"/>
              </group>
              <text variable="page"/>
            </group>
          </else>
        </choose>
      </group>
      <text macro="access" prefix=" "/>
    </layout>
  </bibliography>
</style>

然后在您的 YAML 标头中引用此文件:

After that refer in your YAML Header to this file:

---
title: "title"
bibliography: biblioteka.bib
csl: acm.csl
output:
    pdf_document
---

要更改样式,只需在 CSL-Website 找到另一种引用样式,然后使用不同的 *.csl.

In order to change the style, just find another citation style at the CSL-Website and proceed accordingly with a different *.csl.

为了完整起见,你需要在论文的最后加上参考书目:

For the sake of completeness, at the end of your thesis you need to add the bibliography:

# References
```{r refmgr references, results="asis", echo=FALSE}
# PrintBibliography(bib) 
```

这篇关于r markdown biblio-style 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆