Rmarkdown 中的引用:使用 .bib 文件中的标题大写
Posted
技术标签:
【中文标题】Rmarkdown 中的引用:使用 .bib 文件中的标题大写【英文标题】:References in Rmarkdown: use title capitalization as is in the .bib file 【发布时间】:2020-09-22 09:24:19 【问题描述】:我正在使用带有 RStudio 和 knitr
的 Rmarkdown 编写手稿。为了格式化参考文献,我使用了 Global Ecology and Biogeography 期刊的 .csl
文件,该文件是从 https://www.zotero.org/styles 获得的。
我的问题是标题会自动转换为句子大小写。这对于变成小写的物种名称尤其成问题。
例如,
Two types of morphophysiological dormancy in seeds of two genera (Osmorhiza and Erythronium) with an Arcto-Tertiary distribution pattern
变成
Two types of morphophysiological dormancy in seeds of two genera (osmorhiza and erythronium) with an arcto-tertiary distribution pattern
根据这个问题:How to set references to 'sentence case'?,我应该从.csl
文件中删除像text-case=
这样的所有行。问题是没有这样的行,我的标题仍然被转换了。
另外,我还想知道如何将物种名称保持为斜体。
Rmarkdown 文件
---
title: "Untitled"
output: html_document
bibliography: refs.bib
csl: global-ecology-and-biogeography.csl
link-citations: yes
---
```r setup, include=FALSE
knitr::opts_chunk$set(echo = TRUE)
```
[@RN1045]
# References
带有参考书目的 refs.bib 文件
@articleRN1045,
author = Baskin, Carol C.; Meyer, Susan E.; Baskin, Jerry M.,
title = Two types of morphophysiological dormancy in seeds of two genera (Osmorhiza and Erythronium) with an Arcto-Tertiary distribution pattern,
journal = American Journal of Botany,
volume = 82,
number = 3,
pages = 293-298,
ISSN = 00029122,
DOI = 10.1002/j.1537-2197.1995.tb12633.x,
url = <Go to ISI>://WOS:A1995QM77500001; https://bsapubs.onlinelibrary.wiley.com/doi/abs/10.1002/j.1537-2197.1995.tb12633.x,
year = 1995,
type = Journal Article
global-ecology-and-biogeography.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>Global Ecology and Biogeography</title>
<id>http://www.zotero.org/styles/global-ecology-and-biogeography</id>
<link href="http://www.zotero.org/styles/global-ecology-and-biogeography" rel="self"/>
<link href="http://www.zotero.org/styles/bioinformatics" rel="template"/>
<link href="http://onlinelibrary.wiley.com/journal/10.1111/%28ISSN%291466-8238/homepage/ForAuthors.html" rel="documentation"/>
<author>
<name>Bernhard Hoiß</name>
<email>bernhard.hoiss@uni-wuerzburg.de</email>
</author>
<category citation-format="author-date"/>
<category field="biology"/>
<issn>1466-822X</issn>
<eissn>1466-8238</eissn>
<summary>The Global Ecology and Biogeography style</summary>
<updated>2016-09-10T14:32:31+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>
<locale>
<terms>
<term name="edition" form="short">edn.</term>
<term name="editor" form="verb-short">ed. by</term>
<term name="translator" form="verb-short">trans.</term>
</terms>
</locale>
<macro name="editor">
<names variable="editor" delimiter=",">
<label form="verb-short" prefix=" (" suffix=" "/>
<name sort-separator=", " and="text" initialize-with="." delimiter=", " suffix=")"/>
</names>
</macro>
<macro name="author">
<names variable="author">
<name name-as-sort-order="all" and="symbol" sort-separator=", " initialize-with="." delimiter=", " delimiter-precedes-last="never"/>
<label form="short" prefix=" "/>
<substitute>
<names variable="editor"/>
<text variable="title"/>
</substitute>
</names>
</macro>
<macro name="author-short">
<names variable="author">
<name form="short" and="symbol" delimiter=", " initialize-with=". "/>
<et-al term="et-al" font-style="italic"/>
<substitute>
<names variable="editor"/>
<names variable="translator"/>
<text variable="title"/>
</substitute>
</names>
</macro>
<macro name="title">
<text variable="title"/>
</macro>
<macro name="publisher">
<group delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</macro>
<macro name="year-date">
<date variable="issued">
<date-part name="year"/>
</date>
</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" suffix="."/>
</else>
</choose>
</macro>
<citation et-al-min="3" et-al-use-first="1" disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter=",">
<sort>
<key macro="year-date"/>
<key macro="author-short"/>
</sort>
<layout prefix="(" suffix=")" delimiter="; ">
<group delimiter=", ">
<text macro="author-short"/>
<text macro="year-date"/>
<text variable="locator"/>
</group>
</layout>
</citation>
<bibliography hanging-indent="true" entry-spacing="0">
<sort>
<key macro="author"/>
<key variable="title"/>
</sort>
<layout suffix=".">
<text macro="author"/>
<date variable="issued" prefix=" (" suffix=")">
<date-part name="year"/>
</date>
<choose>
<if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<group delimiter=" " prefix=" ">
<text macro="title" font-style="italic" suffix=","/>
<text macro="edition"/>
<text macro="editor"/>
<text macro="publisher"/>
</group>
</if>
<else-if type="chapter paper-conference" match="any">
<text macro="title" prefix=" " suffix="." font-style="italic"/>
<group prefix=" " suffix=",">
<text variable="container-title" font-style="italic"/>
<text variable="collection-title" prefix=" " suffix="."/>
<text macro="editor"/>
</group>
<group suffix=".">
<group prefix=" " suffix=".">
<label variable="page" suffix=" " form="short"/>
<text variable="page"/>
</group>
<text macro="publisher" prefix=" "/>
</group>
</else-if>
<else>
<text macro="title" prefix=" " suffix="."/>
<group delimiter=", " prefix=" " suffix=".">
<text variable="container-title" form="long" font-style="italic"/>
<text variable="volume" font-weight="bold"/>
<text variable="page"/>
</group>
</else>
</choose>
</layout>
</bibliography>
</style>
【问题讨论】:
【参考方案1】:看起来knitr
使用pandoc-citeproc
进行引用呈现,并且您可以通过在标题周围使用另一组括号来保留大小写。见https://github.com/jgm/pandoc-citeproc/issues/269。
所以不是
title = Two types of morphophysiological dormancy in seeds of two genera (Osmorhiza and Erythronium) with an Arcto-Tertiary distribution pattern
你会使用
title = Two types of morphophysiological dormancy in seeds of two genera (Osmorhiza and Erythronium) with an Arcto-Tertiary distribution pattern
另见https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md#titles-title-vs-sentence-case,
对于物种名称,请尝试\textitOsmorhiza
。 (每https://latex.org/forum/viewtopic.php?t=21255)
【讨论】:
谢谢,这解决了我的问题。对于那些(像我一样)从 EndNote 库生成.bib
文件的人,我将补充一点,您可以编辑 EndNote 的 BibTeX 导出样式,以便在您的标题中插入双 以保护它们免受大小写更改。你也可以在你的 EndNote 引用中插入\textitOsmorhiza
,让斜体在最终文档中使用knitr
生成,但是如果你想在 Word 中使用它会出现这样的情况。【参考方案2】:
如果您想要大写和斜体的物种名称,另一种方法是将物种名称包裹在标题中的\emphspecies name
。
例如:
@articleberra1973,
title = A home range study of \emphGalaxias bongbong in Australia
在此示例中,@Rintze Zelle 使用双花括号的答案需要在“Australia”中保留大写“A”。
我使用 Zotero 作为引文管理器和 RStudio 中的可视化编辑器来查找和填充 RMarkdown 文档的 .bib 文件,如果物种名称包含在 Zotero 标题中的 <i>species name</i>
中,RStudio 可视化编辑器会自动将 .bib 文件中的 <i>species name</i>
替换为 \emphspecies name
。
【讨论】:
您是在回答问题,所以请不要在回答中问反问题?以上是关于Rmarkdown 中的引用:使用 .bib 文件中的标题大写的主要内容,如果未能解决你的问题,请参考以下文章