BibTeX 不适用于相对路径,但使用绝对路径则可以。

BibTeX 不适用于相对路径,但使用绝对路径则可以。

我应该怎么做才能使用相对路径运行 bibtex?

我将一个 .tex 文件和一个 .bib 文件放在同一个目录中。

我使用以下两种情况来运行 bibtex,一种是用相对路径描述,一种是用绝对路径描述。我不确定,但我猜提交时需要相对路径。当我提交论文时,我猜需要在网上编译,如果我使用绝对路径,它不会成功。我重新安装了 2020 版的 tex,但它没有任何变化。

即使我将 .bib 文件放在路径中C:\texlive\texmf-local\bibtex\bib\local,具有相关路径的代码\bibliography{}也不起作用。

1. 相对路径

\bibliography{hoge}

2.绝对路径

  \bibliography{C:/Users/81909/Desktop/SeptFinalWork2020Sept/hoge}

如果我使用前者(1. 相对路径),则会出现以下错误。

This is BibTeX, Version 0.99d (TeX Live 2020/W32TeX)
The top-level auxiliary file: test.aux
The style file: elsarticle-num-names.bst
I couldn't open database file hoge.bib
---line 26 of file test.aux
 : \bibdata{hoge
 :              }
I'm skipping whatever remains of this command
I found no database files---while reading file test.aux
Warning--I didn't find a database entry for "Villani"
Warning--I didn't find a database entry for "Burago"
Warning--I didn't find a database entry for "Gromov"
Warning--I didn't find a database entry for "Flores"
(There were 2 error messages)

根据我应该将 bibfile.bib 放在哪里才能在 \bibliography{bibfile} 中直接使用它?BIBINPUTS = .;$TEXMF/bibtex/bib//,我在位于的文件中插入了该行texmf.cnf C:\texlive\2020\texmf.cnf,然后在命令提示符下运行代码mktexlsr以反映 的修改texmf.cnf

内容我的texmf.cnf路径如下C:\texlive\2020\texmf.cnf

 % (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
OSFONTDIR = $SystemRoot/fonts//
BIBINPUTS = .;$TEXMF/bibtex/bib//

% Prefer external Perl for third-party TeXLive Perl scripts
% Was set to 1 if at install time a sufficiently recent Perl was detected.
TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL = 0

我已经努力了好几天,但没有得到任何解决方案。我是 TeX 的初学者。

答案1

以下是一些针对 bibtex 的建议(因为太大无法评论所以放在这里)。

  1. 用作biber默认的 biblatex 编译器
  2. 保留\usepackage{biblatex}在序言中(您可能希望使用选项进行自定义,例如排序)
  3. 前言类似于\bibliography{filename.bib}
  4. 使用\printbibliography
  5. 确保你的 TeXlive 版本已更新(我的是 2020)

希望您采取所有步骤后不会遇到同样的问题。另外,尽量不要将文件名与父 tex 文件名相同。

相关内容