解決策1

解決策1

次に示すように、sources.bibファイルが自分のファイルと同じディレクトリ内にある場合、引用は正常に機能します。.tex

\documentclass{article}
\usepackage{fancyhdr}

\begin{document}

\thispagestyle{fancy}
\everymath{\displaystyle}

\nocite{textbook}

\bibliographystyle{plain}
\bibliography{sources}

\end{document}

ファイルは次のとおりですsources.bib:

@book{textbook,
    author = {First, Last},
    title = {title},
}

私の参考文献は問題なく表示されます。ただし、単にsources.bib親ディレクトリに移動してコードを調整すると、次のようになります。

\documentclass{article}
\usepackage{fancyhdr}

\begin{document}

\thispagestyle{fancy}
\everymath{\displaystyle}

\nocite{textbook}

\bibliographystyle{plain}
\bibliography{../sources}

\end{document}

次のエラーが表示されます:

Citation `textbook' undefined
Empty `thebibliography' environment
There were undefined references.

ここで何が問題なのですか?

答え1

投稿されたコードを試してみましたU.Martinez-Corralの回答残念ながら、私の環境では動作しません (Windows10 + Sublime Text 3 (Build 3126) + LaTeXTools + Texlive)。

これは BibTeX の制限です:

BibTeX と出力ディレクトリを使用する場合、上方向のディレクトリトラバーサル (..) を必要とする相対パスは機能しません。これは、出力ディレクトリの概念を実際にはサポートしていない BibTeX の制限です。 親ディレクトリに bib ファイルがある場合、引用が見つかりません

解決策1

代わりに絶対パスを使用してください。

\bibliography{../sources}                         % relative path: don't work
\bibliography{E:/GitKraken/test/sources}          % absolute path: work

解決策2

私の解決策は、currfile-abspathパッケージを使用して絶対パスを構築することです\bibliography{\mainabsdir/../sources}

./main.tex

\documentclass[a4paper]{article}
% \usepackage[backend=bibtex]{biblatex}

\usepackage{currfile-abspath}

\getmainfile % get real main file (can be different than jobname in some cases)
\getabspath{\themainfile} % or use \jobname.tex instead (not as safe)
\let\mainabsdir\theabsdir % save result away (macro will be overwritten by the next \getabspath
\let\mainabspath\theabspath % save result away (macro will be overwritten by the next \getabspath

\begin{document}

\cite{knuth1986texbook}

\bibliographystyle{plain}
\bibliography{\mainabsdir/../sources}

\end{document}

参照:https://tex.stackexchange.com/a/54891/115852

答え2

この場合は効果がないはずですが、Minimum Working Example (MWE) をできるだけ小さくして、テストに必要なすべてのファイルを提供することをお勧めします。MWE にはスタイルfancy定義がありません。これを削除し\everymath、bibfile の内容を追加すると、次の MWE が機能します。

./main.tex

\documentclass[a4paper]{article}
\begin{document}

\cite{knuth1986texbook}

\bibliographystyle{plain}
\bibliography{../sources}

\end{document}

../sources.bib

@book{knuth1986texbook,
  keywords = {book},
  title={The texbook},
  author={Knuth, D.E. and Bibby, D.},
  volume={1993},
  year={1986},
  publisher={Addison-Wesley}
}

念のため、補助ファイルをすべて削除し、シーケンス全体を再度コンパイルしてください (pdflatex + bibtex + pdflatex + pdflatex)。それでもまだ動作しませんか?

関連情報