LaTeX - 独立 - 嵌套子文件中的图形引用错误

LaTeX - 独立 - 嵌套子文件中的图形引用错误

几天来我一直被一个问题困扰,没有任何手册或文档可以解决,请帮忙:

我有我的 '主文本' 报告文档文件,我使用 '独立' 包来加载章节内容,如下所示:

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{standalone}
\begin{document}
  \input{chapter-about-this}
  \input{chapter-about-that}
\end{document}

在 - 的里面 '关于此章.tex' 子文件,我使用 '独立' 包也是如此,这个包用于加载带有绘图或其他图片的图表,其中包含数百行源代码:

\documentclass{standalone}
\usepackage{standalone}
\usepackage{pgfplots}
\begin{document}
  \chapter{Very important chapter}
  Blah blah, look at \ref{fig:super-plot}.
  \input{superplot-source-code}
\end{document}

并且这个嵌套的'超级图-源代码.tex'子文件带来情节:

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
  \begin{figure}
    \label{fig:super-plot}
    \caption{Very strange plot}
    ...plot...
  \end{figure}
\end{document}

当我编译章节本身,图形引用构建没有问题。问题来了,当我尝试编译主要的报告文件。图标题有其有序编号,但章节内的引用文本看起来像'啦啦,看看??。' - 用两个问号代替1.2或类似的东西。

例如,使用参考书目输入\引用命令,没有问题,它给出了编号,尽管带有参考书目的源代码也与这个包一起归档(但在第一级包含)。

我发现,那个汇编有“乳胶' 必须重复两三次才能找到所有引用。但我使用 TeXworks 编辑器进行开发,并使用pdfLaTeX+MakeIndex+BibTex同步文本已启用,我希望它应该运行乳胶根据需要多次。那么重点在哪里呢?

答案1

只需编译多次,我就得到了预期的结果。

在此处输入图片描述

\documentclass[12pt,a4paper,oneside]{report}
\usepackage{filecontents}

\begin{filecontents*}{chapter-about-this.tex}
\documentclass{standalone}
\usepackage{standalone}
\usepackage{pgfplots}
\begin{document}
  \chapter{Very important chapter}
  Blah blah, look at \ref{fig:super-plot} 
    \input{superplot-source-code}
\end{document}
\end{filecontents*}



\begin{filecontents*}{superplot-source-code.tex}
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{graphicx}
\begin{document}
  \begin{figure}
    \label{fig:super-plot}
    \caption{Very strange plot}\centering
    \includegraphics[scale=0.5]{example-image}
  \end{figure}
\end{document}
\end{filecontents*}



\usepackage{standalone}
\begin{document}
  \input{chapter-about-this}
\end{document}

相关内容