如何在正文中引用补充内容中的图表?

如何在正文中引用补充内容中的图表?

我正在使用 LaTeX 撰写科学论文,并想引用其他文档中的补充图表。我该怎么做?

例如。在我的主文档中,我想写这样的内容:

\usepackage{cleveref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}
\graphicspath{{../FitData}}

\begin{document}
Here I want to reference a figure that is in my supplementary content \cref{fig:model_selection_criteria}

\end{document}

而在我的补充内容中我有一个图:

\begin{document}
    %% BIC and RSS distributions

    \begin{figure*}[t]
        \centering
        \begin{subfigure}{0.4\textwidth}
        \includegraphics[width=\linewidth]{../FitData/ModelSelectionGraphs/Histogram_smad7_reproduced_BIC}
        \label{fig:model_selection:BIC}
        \caption{BIC}
        \end{subfigure}
        \begin{subfigure}{0.4\textwidth}
        \includegraphics[width=\linewidth]{../FitData/ModelSelectionGraphs/Histogram_smad7_reproduced_RSS}
        \label{fig:model_selection:RSS}
        \caption{RSS}
        \end{subfigure}
    \label{fig:model_selection_criteria}
    \caption{Distribution of Bayesian information criteria (BIC) and RSS values per model}
    \end{figure*}

\end{document}

答案1

使用xr包并说\externaldocument[supp-]{supplementstuff.tex}以便从外部文档加载参考信息supplementstuff.tex,然后应用\ref{supp-fig...}\cref{supp-fig...}以便获取交叉引用。

首先编译补充文件。

请注意,\label必须放置 \caption,之前没有!

主文件

\documentclass{article}

\usepackage{caption}
\usepackage{subcaption}
\usepackage{graphicx}

\usepackage{xr}
\usepackage{cleveref}

\graphicspath{{../FitData}}

\externaldocument[supp-]{supplementstuff}

\begin{document}  
Here I want to reference a figure that is in my supplementary content \cref{supp-fig:model_selection_criteria}
\end{document}

补充材料.tex

\documentclass{article}

\usepackage[demo]{graphicx}

\usepackage{subcaption}
\usepackage{cleveref}



\begin{document}
    %% BIC and RSS distributions

    \begin{figure*}[t]
      \centering
      \begin{subfigure}{0.4\textwidth}
        \includegraphics[width=\linewidth]{../FitData/ModelSelectionGraphs/Histogram_smad7_reproduced_BIC}
        \caption{BIC}
        \label{fig:model_selection:BIC}
      \end{subfigure}
      \begin{subfigure}{0.4\textwidth}
        \includegraphics[width=\linewidth]{../FitData/ModelSelectionGraphs/Histogram_smad7_reproduced_RSS}
        \caption{RSS}
        \label{fig:model_selection:RSS}
      \end{subfigure}
      \caption{Distribution of Bayesian information criteria (BIC) and RSS values per model}
      \label{fig:model_selection_criteria}
    \end{figure*}

\end{document}

相关内容