我想在一个持续存在的问题的GitHub存储库中提出一个与联合jgm/citeproc有关的问题,因为我的问题可能超出了最初问题的范围。
我试图应用评论在GitHub上的线程上提出的一种方法到文件,这样我就可以根据它们的语言在不同的布局中显示英文参考文献和非英语参考资料(中文lang-zh,在这里)。也就是说,当西塞普罗克发现.bib文件的bib条目包含csl的variable (例如lang-zh)时,bib条目显示在csl的if-语句中指定的布局中,如下所示:
<citation>
...
<layout>
<choose>
<if variable="lang-zh">
<!--
Multibyte comma as a deliminater for non-English references
-->
<group delimiter=",">
<text macro="author-short-zh" />
<text macro="issued-year-zh" />
<text macro="citation-locator-zh" />
</group>
</if>
<else>
<!--
Normal comma as a deliminater for references in the default language (English)
-->
<group delimiter=", ">
<text macro="author-short" />
<text macro="issued-year" />
<text macro="citation-locator" />
</group>
</else>
</choose>
</layout>
</citation>但是,即使我在.bib文件中添加诸如lang-zh = {yes}、variable = {lang-zh}或language = {lang-zh}这样的字段,也似乎忽略了.bib文件中的变量/标记,如下所示。
@article{chen2012,
title = {基于电无级变速器的内燃机最优控制策略及整车能量管理},
author = {陈骁 and 黄声华 and 万山明 and 庞珽},
journal = {电工技术学报},
volume = {27},
number = {2},
pages = {133--138},
year = {2012},
lang-zh = {yes},
variable = {lang-zh},
language = {lang-zh}
}那么我应该如何向.bib文件中添加一个可以被csl识别的文件或变量呢?

(M)我们
完整的.csl文件(例如mod_apa_zh_pulipuli.csl)
您可以从.csl找到https://github.com/jgm/citeproc/issues/120#issuecomment-1296207148文件
(它最初的csl名为apa_zh_pulipuli.csl,来自pulipuli.csl)
tests.bib
@book{xie2015,
title = {Dynamic Documents with {R} and knitr},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2015},
edition = {2nd},
note = {ISBN 978-1498716963},
url = {http://yihui.name/knitr/},
language = {English}
}
@article{chen2012,
title = {基于电无级变速器的内燃机最优控制策略及整车能量管理},
author = {陈骁 and 黄声华 and 万山明 and 庞珽},
journal = {电工技术学报},
volume = {27},
number = {2},
pages = {133--138},
year = {2012},
lang-zh = {yes},
variable = {lang-zh},
language = {lang-zh}
}test.md
---
bibliography: [test.bib]
csl: mod_apa_zh_pulipuli.csl
---
@xie2015
@chen2012发布于 2022-11-03 04:53:06
正如@adam.smith所建议的那样,使用CSL (.json)文件作为书目源可以实现以下目的:
.bib将.bib文件转换为CSL (.json)文件(另见TeX.SE中的回答 );"lang-zh": "yes"添加到生成的.json文件(此过程是强制性的,因为.bib中的lang-zh = {yes}这样的非标准字段不会传输到CSL中);.md文件的YAML中的.md字段,以便pandoc可以引用.json文件

米维
test.json
[
{
"URL": "http://yihui.name/knitr/",
"author": [
{
"family": "Xie",
"given": "Yihui"
}
],
"edition": "2nd",
"id": "xie2015",
"issued": {
"date-parts": [
[
2015
]
]
},
"note": "ISBN 978-1498716963",
"publisher": "Chapman; Hall/CRC",
"publisher-place": "Boca Raton, Florida",
"title": "Dynamic Documents with R and knitr",
"type": "book"
},
{
"author": [
{
"family": "陈骁"
},
{
"family": "黄声华"
},
{
"family": "万山明"
},
{
"family": "庞珽"
}
],
"container-title": "电工技术学报",
"id": "chen2012",
"issue": "2",
"issued": {
"date-parts": [
[
2012
]
]
},
"page": "133-138",
"title": "基于电无级变速器的内燃机最优控制策略及整车能量管理",
"type": "article-journal",
"volume": "27",
"lang-zh": "yes"
}
]test.md
---
bibliography: [test.bib]
csl: mod_apa_zh_pulipuli.csl
---
@xie2015
@chen2012https://stackoverflow.com/questions/74255241
复制相似问题