
Я хочу включить изображение TikZ в свой документ. Я хочу, чтобы оно было самодостаточным, чтобы мне не пришлось засорять свой основной документ всеми его преамбулами. Согласноstandalone
руководство(стр. 22) можно включить эти преамбулы с опцией subpreambles
. Но когда я устанавливаю, subpreambles=true
я получаю ошибку, и преамбулы все равно игнорируются. Как мне включить преамбулы кода TikZ?
Это код моего основного документа:
\documentclass{book}
\usepackage{tikz}
\usepackage{standalone}
\begin{document}
Text ...
\begin{figure}
\includestandalone[subpreambles=true]{mytikz}
\caption{My TikZ picture}
\label{fig:tikz:my}
\end{figure}
\end{document}
Это код моей картинки mytikz.tex
:
\documentclass[tikz]{standalone}
\usepackage{tikz}
\tikzstyle{object_representation} = [
align = center,
draw = black,
fill = white,
minimum width = 2cm,
minimum height = 2cm,
rectangle,
rounded corners,
]
\begin{document}
\begin{tikzpicture}[node distance = 3cm]
\node (foo) [object_representation] {Foo};
\end{tikzpicture}
\end{document}
Вот какую ошибку я получаю:
ABD: EveryShipout initializing macros
Package xkeyval Warning: key `subpreambles' has been disabled on input line 7.
(mytikz.tex
! Package pgfkeys Error: I do not know the key '/tikz/object_representation' an
d I am going to ignore it. Perhaps you misspelled it.
See the pgfkeys package documentation for explanation.
Type H <return> for immediate help.
...
l.18 \node (foo) [object_representation]
{Foo};
No pages of output.
Transcript written on main.log.
решение1
Попробуйте следующее:
\documentclass{book}
\usepackage{tikz}
\usepackage[subpreambles=true]{standalone} % <--- option should be here
\begin{document}
Text ...
\begin{figure}
\includestandalone{mytikz}
\caption{My TikZ picture}
\label{fig:tikz:my}
\end{figure}
\end{document}
Редактировать:Я бы написал ваш mytikz
файл короче и с новым синтаксисом для определения стиля формы:
\documentclass[tikz]{standalone}% <-- it is sufficient to has `tikz` only here
\tikzset{object_representation/.style = {% <---
align = center,
draw = black,
fill = white,
minimum width = 2cm,
minimum height = 2cm,
rectangle,
rounded corners}
}
\begin{document}
\begin{tikzpicture}
\node (foo) [object_representation] {Foo};
\end{tikzpicture}
\end{document}