솔루션 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

이 경우 아무런 효과가 없더라도 MWE(최소 작업 예제)를 가능한 한 가장 작게 유지하고 이를 테스트하는 데 필요한 모든 파일을 제공하는 것이 좋습니다. MWE에는 fancy스타일 정의가 부족합니다. 이를 제거하고 \everymathbibfile의 내용을 추가하면 이 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). 아직도 작동하지 않나요?

관련 정보