gpt4 book ai didi

r - 使用带有引用书目样式的 natbib 的 RStudio 进行引用时出现问题

转载 作者:行者123 更新时间:2023-12-04 04:14:24 25 4
gpt4 key购买 nike

考虑以下几点:

测试.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}

测试.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"
}

贾萨.bst

此文件可以在 https://github.com/merliseclyde/AAIS/blob/master/jasa.bst 中找到。或 https://github.com/auk12/MSc-Thesis-backup/blob/master/Bibliography/jasa.bst .

问题描述

在 RStudio 中,当我使用 test.rnw 点击“编译 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.textest.bbl 是创建。有趣的是,test.pdf 编译正确并且可以通过 TeXworks 查看。我可以使用 Windows 资源管理器清楚地查看 .bbl 和 .pdf 文件。

但是当我在通过 TeXworks 编译后在 RStudio 中点击“编译 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。

最佳答案

这个问题终于在RStudio IDE中解决了,修复会出现在RStudio 1.4之后的patch release中,目前还没有。目前你必须使用 RStudio 的日常构建:https://dailies.rstudio.com

Tools -> Global Options 中,您可以选中“在编译 .tex 文件时使用 tinytex”复选框:

Use tinytex to compile .tex in RStudio

那么应该正确编译引用书目。

关于r - 使用带有引用书目样式的 natbib 的 RStudio 进行引用时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61029677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com