未能在其他 tex 文件中使用参考书目

未能在其他 tex 文件中使用参考书目

我有两个 .tex 文件:reftest.tex,其中包含主要详细信息:参考文献、图表、公式;和 cross_ref.tex。在 cross_ref.tex 中,我想交叉引用 reftest.tex 文件中的参考文献。但是,引用失败。你能帮我修复它吗?这是我的代码

在 reftest.tex 中:

 \documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage[draft]{hyperref}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}
This is ref \cite{S_Goossens}

\begin{figure} 
  \centering \includegraphics[width=0.5\linewidth]{example-image-a}
  \caption{This is caption}
  \label{fig:2}
\end{figure}

\begin{equation}
\label{eq:1} 
  y=x
\end{equation}

\begin{thebibliography}{00}

%% Text of bibliographic item
\bibitem{S_Goossens}SMichel Goossens, Frank Mittelbach, and Alexander Samarin Addison-Wesley, Reading, Massachusetts, 1993.

\end{thebibliography}
\end{document}

在 cross_ref.tex 中

\documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage[draft]{hyperref}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{xr}
\externaldocument{reftest}

\begin{document}
This is ref \cite{S_Goossens} in the reftest file

Figure \ref{fig:1} is figure in the reftest file

The  Eq. \eqref{eq:1} is a equation 

\end{document}

我的输出无法显示 cross_ref.tex 文件中的引用数

在此处输入图片描述

答案1

xcite似乎可以工作。请注意xr-hyper而不是 `xr 和包加载顺序。

reftest.tex

\documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[draft]{hyperref}

\begin{document}
This is ref \cite{S_Goossens}

\begin{figure} 
  \centering \includegraphics[width=0.5\linewidth]{example-image-a}
  \caption{This is caption}
  \label{fig:1}
\end{figure}

\begin{equation}
\label{eq:1} 
  y=x
\end{equation}

\begin{thebibliography}{00}

%% Text of bibliographic item
\bibitem{S_Goossens} Michel Goossens, Frank Mittelbach, and Alexander Samarin 
Addison-Wesley, Reading, Massachusetts, 1993.

\end{thebibliography}
\end{document}

crossref.tex

\documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{xcite}
\usepackage{xr-hyper}
\usepackage[draft]{hyperref}
\externaldocument{reftest}
\externalcitedocument{reftest}

\begin{document}
This is ref \cite{S_Goossens} in the reftest file

Figure \ref{fig:1} is figure in the reftest file

The  Eq. \eqref{eq:1} is a equation 

\end{document}

输出crossref.tex

在此处输入图片描述

答案2

好的,这是一个解决方案。

如果您使用外部书目文件(literatur.bib):

    @BOOK{S_Goossens,
  title = {Some title},
  publisher = {Addison-Wesley},
  year = {1993},
  author = {Goossens, S. Michel and Mittelbach, Frank and Samarin, Alexander},
  address = {Reading, Massachusetts},
  owner = {polz},
  timestamp = {2016.03.24}
}

您只需要更改 reftest.tex 以使用外部书目而不是使用环境thebibliography

\documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage[draft]{hyperref}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}
This is ref \cite{S_Goossens}

\begin{figure} 
  \centering \includegraphics[width=0.5\linewidth]{example-image-a}
  \caption{This is caption}
  \label{fig:1}
\end{figure}

\begin{equation}
\label{eq:1} 
  y=x
\end{equation}

\bibliography{literatur}{}
\bibliographystyle{plain}

\end{document}

如果您现在\usepackage{bibentry}在 cross_rex.tex 的序言中包含该命令,并通过 包含 literatur.bib \nobibliography{literatur}{}(这会阻止打印参考书目),那么它就会按照您想要的方式工作。

\documentclass[preprint,12pt, sort&compress]{elsarticle}
\def\bibsection{\section*{References}}
\usepackage[draft]{hyperref}
\usepackage{graphicx}
\usepackage{caption,subfig}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{xr}
\externaldocument{reftest}

\usepackage{bibentry}

\begin{document}
This is ref \cite{S_Goossens} in the reftest file

Figure \ref{fig:1} is figure in the reftest file

The  Eq. \eqref{eq:1} is a equation 

\nobibliography{literatur}{}

\end{document}

在此处输入图片描述

相关内容