使用带有参考书目样式的 natbib 的 RStudio 进行引用时出现问题
Problems doing citations using RStudio with natbib with a bibliography style
考虑以下几点:
test.rnw
\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage[margin=1in]{geometry}
\begin{document}
<<setup, include = FALSE, echo = FALSE>>=
Sys.setenv(TEXINPUTS = getwd(),
BIBINPUTS = getwd(),
BSTINPUTS = getwd())
@
Some text \citet{brockwelldavis}
\newpage
\nocite{*}
\bibliographystyle{jasa}
\bibliography{test}
\end{document}
test.bib
@book{brockwelldavis,
author = {Brockwell, Peter J. and Davis, Richard A.},
year = 2016,
title = "Introduction to Time Series and Forecasting",
editor = "",
publisher = "Springer International Publishing",
address = "Switzerland"
}
jasa.bst
可以在 https://github.com/merliseclyde/AAIS/blob/master/jasa.bst or https://github.com/auk12/MSc-Thesis-backup/blob/master/Bibliography/jasa.bst.
中找到此文件
问题描述
在 RStudio 中,当我使用 test.rnw
点击 "Compile PDF" 时,我得到
output file: test.tex
[1] "test.tex"
Running pdflatex.exe on test.tex...failed
Issues: 2 warnings
并从日志文件中:
Package natbib Warning: Citation `brockwelldavis' on page 1 undefined on input
line 58.
[1
{C:/Users/[my name]/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
No file test.bbl.
Package natbib Warning: There were undefined citations.
因此,我在 TeXworks 中使用 pdfLaTeX + MakeIndex + BibTeX 从 test.rnw
创建了 运行 test.tex
,并创建了 test.bbl
。有趣的是,test.pdf
编译正确,可以通过 TeXworks 查看。我可以使用 Windows Explorer 清楚地显示 .bbl 和 .pdf 文件。
但是当我通过 TeXworks 编译后在 RStudio 中点击 "Compile PDF" 时,我仍然得到与上面相同的警告。有人知道如何解决这个问题吗?
补充说明
同样令人费解的是,在我的旧计算机上,test.rnw
编译正常,无需使用 TeXworks 作为中间步骤,而在我的新计算机上,它不会。我能想到的唯一区别是,也许我的新电脑有更多更新版本的 R 和 MikTeX。我也尝试在我的新电脑上卸载并重新安装 MikTeX,但仍然 运行 遇到同样的问题。
新计算机设置:
来自 R(使用 RStudio 1.2.5033):
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3
通过Windows命令提示符:
> pdftex --version
MiKTeX-pdfTeX 2.9.7338 (1.40.21) (MiKTeX 2.9.7380 64-bit)
Copyright (C) 1982 D. E. Knuth, (C) 1996-2020 Han The Thanh
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.61.1; using libcurl/7.61.1 WinSSL
compiled with expat version 2.2.6; using expat_2.2.6
compiled with jpeg version 9.3
compiled with liblzma version 50020042; using 50020042
compiled with libpng version 1.6.37; using 1.6.37
compiled with libressl version LibreSSL 2.8.2; using LibreSSL 2.8.2
compiled with MiKTeX Application Framework version 4.7348; using 4.7348
compiled with MiKTeX Core version 16.7375; using 16.7375
compiled with MiKTeX Archive Extractor version 1.6882; using 1.6882
compiled with MiKTeX Package Manager version 9.7364; using 9.7364
compiled with poppler version 0.60.1
compiled with uriparser version 0.9.2
compiled with zlib version 1.2.11; using 1.2.11
旧计算机设置:
来自 R(使用 RStudio 1.2.5001):
> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.2 tools_3.6.2
通过Windows命令提示符:
> pdftex --version
MiKTeX-pdfTeX 2.9.6050 (1.40.17) (MiKTeX 2.9 64-bit)
Copyright (C) 1982 D. E. Knuth, (C) 1996-2016 Han The Thanh
TeX is a trademark of the American Mathematical Society.
compiled with zlib version 1.2.8; using 1.2.8
compiled with libpng version 1.6.24; using 1.6.24
compiled with poppler version 0.46.0
compiled with jpeg version 8.4
两者都在 RStudio 中基于工具 > 全局选项 > Sweave 使用 knitr 和 pdfLaTeX。
我在 Windows 上遇到了类似的问题。我尝试使用 R-studio 和 Miktex,但没有生成书目引用。我安装了 TinyTex,但它与 Texmaker 有冲突。解决方案:我安装了完整的 Texlive。现在一切正常。
RStudio (1.3.959)、R (4.0.2)、Texlive (2020-r55535)、Texmaker 5.0.4、Windows 10 x64 单语言。
这个问题终于在RStudio IDE中解决了,修复会出现在RStudio 1.4之后的patch release中,目前还没有。目前您必须使用 RStudio 的日常构建:https://dailies.rstudio.com
在Tools -> Global Options
中,您可以勾选“编译.tex文件时使用tinytex”复选框:
那么参考书目应该编译正确了。
考虑以下几点:
test.rnw
\documentclass[12pt]{article}
\usepackage{natbib}
\usepackage[margin=1in]{geometry}
\begin{document}
<<setup, include = FALSE, echo = FALSE>>=
Sys.setenv(TEXINPUTS = getwd(),
BIBINPUTS = getwd(),
BSTINPUTS = getwd())
@
Some text \citet{brockwelldavis}
\newpage
\nocite{*}
\bibliographystyle{jasa}
\bibliography{test}
\end{document}
test.bib
@book{brockwelldavis,
author = {Brockwell, Peter J. and Davis, Richard A.},
year = 2016,
title = "Introduction to Time Series and Forecasting",
editor = "",
publisher = "Springer International Publishing",
address = "Switzerland"
}
jasa.bst
可以在 https://github.com/merliseclyde/AAIS/blob/master/jasa.bst or https://github.com/auk12/MSc-Thesis-backup/blob/master/Bibliography/jasa.bst.
中找到此文件问题描述
在 RStudio 中,当我使用 test.rnw
点击 "Compile PDF" 时,我得到
output file: test.tex
[1] "test.tex"
Running pdflatex.exe on test.tex...failed
Issues: 2 warnings
并从日志文件中:
Package natbib Warning: Citation `brockwelldavis' on page 1 undefined on input
line 58.
[1
{C:/Users/[my name]/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}]
No file test.bbl.
Package natbib Warning: There were undefined citations.
因此,我在 TeXworks 中使用 pdfLaTeX + MakeIndex + BibTeX 从 test.rnw
创建了 运行 test.tex
,并创建了 test.bbl
。有趣的是,test.pdf
编译正确,可以通过 TeXworks 查看。我可以使用 Windows Explorer 清楚地显示 .bbl 和 .pdf 文件。
但是当我通过 TeXworks 编译后在 RStudio 中点击 "Compile PDF" 时,我仍然得到与上面相同的警告。有人知道如何解决这个问题吗?
补充说明
同样令人费解的是,在我的旧计算机上,test.rnw
编译正常,无需使用 TeXworks 作为中间步骤,而在我的新计算机上,它不会。我能想到的唯一区别是,也许我的新电脑有更多更新版本的 R 和 MikTeX。我也尝试在我的新电脑上卸载并重新安装 MikTeX,但仍然 运行 遇到同样的问题。
新计算机设置:
来自 R(使用 RStudio 1.2.5033):
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.3 tools_3.6.3
通过Windows命令提示符:
> pdftex --version
MiKTeX-pdfTeX 2.9.7338 (1.40.21) (MiKTeX 2.9.7380 64-bit)
Copyright (C) 1982 D. E. Knuth, (C) 1996-2020 Han The Thanh
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.61.1; using libcurl/7.61.1 WinSSL
compiled with expat version 2.2.6; using expat_2.2.6
compiled with jpeg version 9.3
compiled with liblzma version 50020042; using 50020042
compiled with libpng version 1.6.37; using 1.6.37
compiled with libressl version LibreSSL 2.8.2; using LibreSSL 2.8.2
compiled with MiKTeX Application Framework version 4.7348; using 4.7348
compiled with MiKTeX Core version 16.7375; using 16.7375
compiled with MiKTeX Archive Extractor version 1.6882; using 1.6882
compiled with MiKTeX Package Manager version 9.7364; using 9.7364
compiled with poppler version 0.60.1
compiled with uriparser version 0.9.2
compiled with zlib version 1.2.11; using 1.2.11
旧计算机设置:
来自 R(使用 RStudio 1.2.5001):
> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.2 tools_3.6.2
通过Windows命令提示符:
> pdftex --version
MiKTeX-pdfTeX 2.9.6050 (1.40.17) (MiKTeX 2.9 64-bit)
Copyright (C) 1982 D. E. Knuth, (C) 1996-2016 Han The Thanh
TeX is a trademark of the American Mathematical Society.
compiled with zlib version 1.2.8; using 1.2.8
compiled with libpng version 1.6.24; using 1.6.24
compiled with poppler version 0.46.0
compiled with jpeg version 8.4
两者都在 RStudio 中基于工具 > 全局选项 > Sweave 使用 knitr 和 pdfLaTeX。
我在 Windows 上遇到了类似的问题。我尝试使用 R-studio 和 Miktex,但没有生成书目引用。我安装了 TinyTex,但它与 Texmaker 有冲突。解决方案:我安装了完整的 Texlive。现在一切正常。
RStudio (1.3.959)、R (4.0.2)、Texlive (2020-r55535)、Texmaker 5.0.4、Windows 10 x64 单语言。
这个问题终于在RStudio IDE中解决了,修复会出现在RStudio 1.4之后的patch release中,目前还没有。目前您必须使用 RStudio 的日常构建:https://dailies.rstudio.com
在Tools -> Global Options
中,您可以勾选“编译.tex文件时使用tinytex”复选框:
那么参考书目应该编译正确了。