我的 TeX 经验有限,所以请原谅这个简单的问题。我花了几个小时试图解决这个问题,但无济于事。
我正在尝试使用这里提供的 CJK 芝加哥风格作者日期书目的代码回答。
我想调整代码以用于最新版本的 RStudio 中的 R Markdown 文档。
我正在尝试调整的代码(从上面的链接复制):
\documentclass{article}
\usepackage[fallback]{xeCJK}
\usepackage{xunicode-addon}
\setmainfont[Ligatures={Common, TeX}]{Times New Roman}
\setCJKmainfont[Scale=1]{SimSun}
\usepackage{filecontents}
\begin{filecontents*}{chicago-notes.dbx}
\ProvidesFile{chicago-notes.dbx}[2016/07/24 extended name format for biblatex]
\DeclareDatamodelConstant[type=list]{nameparts}{prefix,family,suffix,given,cjk}
\end{filecontents*}
\begin{filecontents*}{\jobname.bib}
@book{zhaos,
title={A Nation-State by Construction: Dynamics of Modern Chinese Nationalism},
author={given=Suisheng, family=Zhao, cjk=趙歲升},
isbn={9780804750011},
year={2011},
address = {Stanford},
publisher={Stanford University Press}}
@book{jim,
title={Lorem},
author={Smith, Junior, Jim},
year={2009},
address = {Stanford},
publisher={Stanford University Press}}
\end{filecontents*}
\usepackage[notes,strict,annotation,cmsdate=both,isbn=false, backend=biber]{biblatex-chicago}
\addbibresource{\jobname.bib}
% Based on definitions from biblatex.def
\newbibmacro*{name:cjk}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamefamily{#1}%
\ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}%
\ifdefvoid{#3}{}{\bibnamedelimd\mkbibnamecjk{#3}}}
\newbibmacro*{name:cjk-nocjk}[3]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\mkbibnamefamily{#1}%
\ifdefvoid{#2}{}{\bibnamedelimd\mkbibnamegiven{#2}}}
\DeclareNameFormat{labelname}{%
\ifcase\value{uniquename}%
\usebibmacro{name:family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}%
\or
\ifdefvoid{\namepartcjk}
{\ifuseprefix
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffixi}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefixi}
{\namepartsuffixi}}}
{\usebibmacro{name:cjk-nocjk}
{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
\or
\ifdefvoid{\namepartcjk}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:name:cjk-nocjk}
{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
\fi
\usebibmacro{name:andothers}}
\DeclareNameFormat{family-given}{%
\ifdefvoid{\namepartcjk}
{\ifgiveninits
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
\usebibmacro{name:andothers}}
\DeclareNameFormat{given-family}{%
\ifdefvoid{\namepartcjk}
{\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
\usebibmacro{name:andothers}}
\DeclareNameFormat{family-given/given-family}{%
\ifdefvoid{\namepartcjk}
{\ifnumequal{\value{listcount}}{1}
{\ifgiveninits
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}%
\ifboolexpe{%
test {\ifdefvoid\namepartgiven}
and
test {\ifdefvoid\namepartprefix}}
{}
{\usebibmacro{name:revsdelim}}}
{\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}}
{\usebibmacro{name:cjk}{\namepartfamily}{\namepartgiven}{\namepartcjk}}%
\usebibmacro{name:andothers}}
\DeclareFieldFormat[book]{title}{%
\mkbibemph{#1}%
\iffieldundef{titleaddon}{\isdot}{\nopunct}}
\DeclareFieldFormat{booktitle}{%
\mkbibemph{#1}%
\iffieldundef{booktitleaddon}{}{\nopunct}}
\DeclareFieldFormat{maintitle}{%
\mkbibemph{#1}%
\iffieldundef{maintitleaddon}{}{\nopunct}}
\DeclareFieldFormat[article]{title}{%
\iffieldundef{title}{}{\mkbibquote{#1}}%
\iffieldundef{titleaddon}{\isdot}{\nopunct}}
\DeclareFieldFormat{usere}{\mkbibparens{#1}}
\begin{document}
\cite{zhaos,jim}
\printbibliography
\end{document}
我的 .Rmd 文件的 YAML 是
title: "Title"
output:
html_document:
number_sections: T
includes:
in_header: "preamble.tex"
link-citations: T
mainfont: Latin Modern
nocite: '@*'
citation_package: biblatex
文件“preamble.tex”由上面的 CJK 代码组成。当我编织文件时,“preamble.tex”显示为文本,参考书目不反映 CJK 改编。(我还尝试删除 CJK 代码中的参考资料,并将它们放在“refs.bib”文件中,我将该文件添加到 YAML 中。这没有帮助。)
有人能指导如何在我的 RStudio IDE 中实现此代码吗?非常感谢!