독립형 TikZ 이미지를 포함할 때 하위 프리앰블을 어떻게 통합하나요?

독립형 TikZ 이미지를 포함할 때 하위 프리앰블을 어떻게 통합하나요?

내 문서에 TikZ 이미지를 포함하고 싶습니다. 나는 그것이 독립적이기를 원하므로 모든 서문으로 주요 문서를 오염시킬 필요가 없습니다. 에 따르면standalone수동(p. 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}

관련 정보