bookdown 中不同引文包的问题
Issues with different citation packages in bookdown
我正在使用 bookdown 创建一个 pdf-book,其中包含一个包含我的引文的 .bib 文件。我用 bookdown 中使用的标准 [@citation]
调用引用。引用工作正常,但参考书目似乎不是我想要的。
以下是我需要处理的事情:
参考书目应该包含在目录中,在 \mainmatter
的末尾,但在 \backmatter
之前,我用它作为附录附上 pdf,其中目录
中列出了附录 header
in-text 引用应采用数字格式,可能存在嵌套引用,如下所示:[1,2]
参考书目应该按照它们在正文中出现的顺序排列,可以删除我认为合适的DOI/URLs等
到目前为止,为了让这些东西正常工作,我已经尝试了 natbib
包,它似乎工作正常。但是,我似乎无法从特定的参考书目条目(例如期刊文章)中删除 DOI/URLs。因此,我尝试使用 biblatex 或 built-in pandoc,但它们似乎都无法正常工作(使用 pandoc 时,参考书目从目录中消失,参考书目条目很乱。使用 biblatex,我得到了程序可以解决的多个错误在 .bib 文件中找不到特定条目,它们在那里)
这是我的带有 natbib 的 YAML:
site: bookdown::bookdown_site
geometry: "left=4cm,right=3cm,top=3cm,bottom=3cm"
subparagraph: true
output:
bookdown::pdf_book:
latex_engine: xelatex
fig_caption: yes
toc: false
citation_package: natbib
includes:
before_body: frontpage.tex
after_body: after_body.tex
in_header: preamble.tex
fontsize: 11pt
linestretch: 1.2
documentclass: book
bibliography: [packages.bib, libraryzotero.bib]
link-citations: yes
---
这是我的 preamble.tex:
\usepackage{titlesec}
\usepackage{pdfpages}
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter}{1em}{} % set title format
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\AtBeginDocument{\let\maketitle\relax}
\usepackage{makeidx}
\makeindex
\setcitestyle{numbers,square,comma}
\usepackage{url}
\usepackage[nottoc]{tocbibind}
\usepackage{caption}
\captionsetup[figure]{textfont={small,it}, labelfont={normalsize,bf,it}} % set figure caption font size and style
\usepackage{graphicx}
\usepackage{float}
\let\origfigure\figure
\let\endorigfigure\endfigure
\renewenvironment{figure}[1][2] {
\expandafter\origfigure\expandafter[H]
} {
\endorigfigure
}
\raggedbottom
\usepackage{fancyhdr,blindtext}
\fancyhf{}
\fancyhead[LO]{\slshape \rightmark} %section
\fancyhead[RO]{\thepage}
\fancyhead[RE]{\slshape \leftmark} % chapter
\fancyhead[LE]{\thepage}
\setlength{\headheight}{27.7pt} % as requested by fancyhdr's warning
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\makeatletter
\renewcommand{\chaptermark}[1]{% % change settings for including headers
\if@mainmatter
\markboth{Chapter \thechapter{}: #1}{}%
\else
\markboth{#1}{}%
\fi
}
\makeatother
\usepackage{epigraph}
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}
其中 \setcitestyle{numbers, square, comma}
用于 in-text 参考文献。
有没有人对如何让这些东西与 bookdown 一起工作有任何建议?
对于基于 natbib
的解决方案,您可以修补使用的参考书目样式:
- 您没有设置任何参考书目样式。因此使用
plainnat.bst
。
- 使用新名称将
plainnat.bst
从您的 TeX 安装(通常 TEXMF/bibtex/bst/natbib/
)复制到您的工作目录。
- 将
biblio-style: <new-name>
添加到您的 YAML header。
- 编辑您的 BST 文件:
- 找到
FUNCTION {article}
.
- 在该块中删除
format.doi output
和 format.url output
。
- 重复其他类型。
我正在使用 bookdown 创建一个 pdf-book,其中包含一个包含我的引文的 .bib 文件。我用 bookdown 中使用的标准 [@citation]
调用引用。引用工作正常,但参考书目似乎不是我想要的。
以下是我需要处理的事情:
参考书目应该包含在目录中,在
\mainmatter
的末尾,但在\backmatter
之前,我用它作为附录附上 pdf,其中目录 中列出了附录 header
in-text 引用应采用数字格式,可能存在嵌套引用,如下所示:[1,2]
参考书目应该按照它们在正文中出现的顺序排列,可以删除我认为合适的DOI/URLs等
到目前为止,为了让这些东西正常工作,我已经尝试了 natbib
包,它似乎工作正常。但是,我似乎无法从特定的参考书目条目(例如期刊文章)中删除 DOI/URLs。因此,我尝试使用 biblatex 或 built-in pandoc,但它们似乎都无法正常工作(使用 pandoc 时,参考书目从目录中消失,参考书目条目很乱。使用 biblatex,我得到了程序可以解决的多个错误在 .bib 文件中找不到特定条目,它们在那里)
这是我的带有 natbib 的 YAML:
site: bookdown::bookdown_site
geometry: "left=4cm,right=3cm,top=3cm,bottom=3cm"
subparagraph: true
output:
bookdown::pdf_book:
latex_engine: xelatex
fig_caption: yes
toc: false
citation_package: natbib
includes:
before_body: frontpage.tex
after_body: after_body.tex
in_header: preamble.tex
fontsize: 11pt
linestretch: 1.2
documentclass: book
bibliography: [packages.bib, libraryzotero.bib]
link-citations: yes
---
这是我的 preamble.tex:
\usepackage{titlesec}
\usepackage{pdfpages}
\titleformat{\chapter}
{\normalfont\LARGE\bfseries}{\thechapter}{1em}{} % set title format
\titlespacing*{\chapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\AtBeginDocument{\let\maketitle\relax}
\usepackage{makeidx}
\makeindex
\setcitestyle{numbers,square,comma}
\usepackage{url}
\usepackage[nottoc]{tocbibind}
\usepackage{caption}
\captionsetup[figure]{textfont={small,it}, labelfont={normalsize,bf,it}} % set figure caption font size and style
\usepackage{graphicx}
\usepackage{float}
\let\origfigure\figure
\let\endorigfigure\endfigure
\renewenvironment{figure}[1][2] {
\expandafter\origfigure\expandafter[H]
} {
\endorigfigure
}
\raggedbottom
\usepackage{fancyhdr,blindtext}
\fancyhf{}
\fancyhead[LO]{\slshape \rightmark} %section
\fancyhead[RO]{\thepage}
\fancyhead[RE]{\slshape \leftmark} % chapter
\fancyhead[LE]{\thepage}
\setlength{\headheight}{27.7pt} % as requested by fancyhdr's warning
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\makeatletter
\renewcommand{\chaptermark}[1]{% % change settings for including headers
\if@mainmatter
\markboth{Chapter \thechapter{}: #1}{}%
\else
\markboth{#1}{}%
\fi
}
\makeatother
\usepackage{epigraph}
\setcounter{secnumdepth}{1}
\setcounter{tocdepth}{1}
其中 \setcitestyle{numbers, square, comma}
用于 in-text 参考文献。
有没有人对如何让这些东西与 bookdown 一起工作有任何建议?
对于基于 natbib
的解决方案,您可以修补使用的参考书目样式:
- 您没有设置任何参考书目样式。因此使用
plainnat.bst
。 - 使用新名称将
plainnat.bst
从您的 TeX 安装(通常TEXMF/bibtex/bst/natbib/
)复制到您的工作目录。 - 将
biblio-style: <new-name>
添加到您的 YAML header。 - 编辑您的 BST 文件:
- 找到
FUNCTION {article}
. - 在该块中删除
format.doi output
和format.url output
。 - 重复其他类型。
- 找到