你好,我正在尝试使用全局 BibTeX 文件在子文件中引用,但我一直收到以下错误
您引用了参考书目中未包含的内容。请确保引用 (\cite{...}) 在您的参考书目中有对应的键,并且两者的拼写相同。
我的代码如下。对于我的,main.tex
我有
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=3cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage{color}
\definecolor{note_fontcolor}{rgb}{0.800781, 0.800781, 0.800781}
\usepackage{array}
\usepackage{verbatim}
\usepackage{rotfloat}
\usepackage{url}
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{textcomp}
\bibliographystyle{plain}
\usepackage{subfiles}
\doublespacing
\makeatletter
% curse you, \@onlypreamble\@ifclassloaded
\newcommand*{\subfilesbibliography}[1]{%
\expandafter\ifx\csname [email protected]\endcsname\relax
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi
{\bibliography{#1}}
{}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
%% The greyedout annotation environment
\newenvironment{lyxgreyedout}
{\textcolor{note_fontcolor}\bgroup\ignorespaces}
{\ignorespacesafterend\egroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
\ifx\proof\undefined
\newenvironment{proof}[1][\protect\proofname]{\par
\normalfont\topsep6\p@\@plus6\p@\relax
\trivlist
\itemindent\parindent
\item[\hskip\labelsep\scshape #1]\ignorespaces
}{%
\endtrivlist\@endpefalse
}
\providecommand{\proofname}{Proof}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{amsmath,epsfig,natbib,amssymb,wrapfig,threeparttable,rotating}
\makeatother
\usepackage{babel}
\providecommand{\theoremname}{Theorem}
\begin{document}
\section{Introduction}
\subfile{Sections/Introduction}
\newpage
\bibliography{My_lib}
\end{document}
Introduction.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
Cluster analysis \cite{hoff_subset_2005} is a popular...
\subfilesbibliography{My_lib}
\end{document}
My_lib.bib 文件从 Zotero 导出为 Bibtex 文件,这是其条目
@article{hoff_subset_2005,
title = {Subset {Clustering} of {Binary} {Sequences}, with an {Application} to {Genomic} {Abnormality} {Data}},
volume = {61},
issn = {1541-0420},
url = {http://onlinelibrary.wiley.com/doi/abs/10.1111/j.1541-0420.2005.00381.x},
doi = {10.1111/j.1541-0420.2005.00381.x},
abstract = {This article develops a model-based approach to clustering multivariate binary data, in which the attributes that distinguish a cluster from the rest of the population may depend on the cluster being considered. The clustering approach is based on a multivariate Dirichlet process mixture model, which allows for the estimation of the number of clusters, the cluster memberships, and the cluster-specific parameters in a unified way. Such a clustering approach has applications in the analysis of genomic abnormality data, in which the development of different types of tumors may depend on the presence of certain abnormalities at subsets of locations along the genome. Additionally, such a mixture model provides a nonparametric estimation scheme for dependent sequences of binary data.},
language = {en},
number = {4},
urldate = {2021-09-28},
journal = {Biometrics},
author = {Hoff, Peter D.},
year = {2005},
note = {\_eprint: https://onlinelibrary.wiley.com/doi/pdf/10.1111/j.1541-0420.2005.00381.x},
keywords = {Genetic pathway, Multivariate binary data, Nonparametric Bayes, Unsupervised learning},
pages = {1027--1036},
file = {Snapshot:C\:\\Users\\Pottie\\Zotero\\storage\\9JT58QWX\\j.1541-0420.2005.00381.html:text/html;Full Text PDF:C\:\\Users\\Pottie\\Zotero\\storage\\NM6C2AGC\\Hoff - 2005 - Subset Clustering of Binary Sequences, with an App.pdf:application/pdf},
}
我使用的密钥与 My_lib.bib 文件中的密钥完全相同,所以我不明白为什么我的引用不起作用。
先感谢您
答案1
在 中Introduction.tex
,替换
\subfilesbibliography{My_lib}
经过
\subfilesbibliography{../My_lib}
一般原理是子文件中的文件名与子文件相关。
使用最新版本的subfiles
软件包,您不必定义\subfilesbibliography
,但可以用以下代码替换上面的代码
\ifSubfilesClassLoaded{\bibliography{../My_lib}}{}% \ifSubfilesClassLoaded{then branch}{else branch}