如何使独立文档的(完整)序言可供“主文档”使用?

如何使独立文档的(完整)序言可供“主文档”使用?

我正在为演示文稿和脚本生成大量内容。独立包和文档类似乎非常有用,但我遇到了 Diac Busquets 提到的问题这里

能否以某种方式告诉独立程序复制所包含文件的前言? 不断复制所有 \usetikzlibrary 命令有时很麻烦。

我已经尝试在主文件中使用subpreamble=truesort=true选项。但不知何故,当我使用选项时,演示文稿编译得很好,但我的“独立表”没有显示(“独立 tikz”会显示)。当我使用 时,包选项会发生冲突(无论我如何重新排列包)standalone packagesort=truesubpreamble=true

问题1:为什么\includestandalone{my tables}没有结果?

为什么我不能使用命令\IfStandalone{⟨code for standalone mode⟩}{⟨code for main document⟩}并将我的\usetikzlibrary语句放在两个花括号(对)中。“双重代码”似乎没有必要,但它应该可以工作!对吧?...我试过了,但没有任何运气。

主文档似乎忽略了该{⟨code for main document⟩}语句。即使我使用了该sort选项。

问题 2:为什么该{⟨code for main document⟩}声明在主文档中被忽略?usetikzlibrary{mylibraries}具体来说,我怎样才能防止在主文档中“重复使用” ?

问题 3:我该如何修复它?

这是 StandalonePicture.tex

\documentclass[convert]{standalone}
\usepackage{tikz}

\IfStandalone{ 
\usetikzlibrary{arrows,decorations.pathmorphing,decorations.markings,decorations.text,}
\tikzset{>=latex}
}
{
% This command does not seem to have an effect in the main document
\usetikzlibrary{arrows,decorations.pathmorphing,decorations.markings,decorations.text,}
\tikzset{>=latex}
}

\begin{document}
\begin{tikzpicture}[node distance=3cm,]

%Define main nodes
\tikzstyle{main node}=[black,draw,circle,minimum size=2.cm,align=center]

% Draw actual nodes
\node [main node] (1) {Text 1}; 
\node [main node] (2) [ left of=1, ] {Text 2};

% Connecting Arrows
\draw [<-,postaction={decorate,decoration={text along path,raise=-2.5mm,text align=center,text={|\tiny| Bending}}}] (2) to [bend right=-45]  (1);

\end{tikzpicture}
\end{document}

这是调用 tikzpicture(或表格)的实际演示文稿(Presentation.tex)

\documentclass[]{beamer}

% It does NOT work with the following line (but it should)
% I don't understand, because the \IfStandalone{}{} command should take care of that.
\usepackage{standalone}


% It does work if the sort option is enabled 
% (Of course, since the 'sort' option ensures that the 'subpreamble' is reprinted)
%\usepackage[sort=true]{standalone}


\begin{document}

%%%%%%%%%%%%%%%%%%%
% Begin Unit %%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Frame 1}
\framesubtitle{This one works flawlessly}
\begin{itemize}
\item First slide with no picture
\end{itemize}
\end{frame}
% ---------------------
% Notes ------------
% ---------------------
\note{
\begin{itemize}
\item This works
\end{itemize}
}
% ---------------------
% Skript ------------
% -------------------------------
\mode<article>{

}
%%%%%%%%%%%%%%%%%%%
% End Unit %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%
% Begin Unit %%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\begin{frame}
\frametitle{Frame 1}
\framesubtitle{This one won't work because of missing tikzlibrary}

\includestandalone{StandalonePicture}

\end{frame}
% ---------------------
% Notes ------------
% ---------------------
\note{
\begin{itemize}
\item This works
\end{itemize}
}
% ---------------------
% Skript ------------
% -------------------------------
\mode<article>{

}
%%%%%%%%%%%%%%%%%%%
% End Unit %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%

\end{document}

相关内容