0

I have a standalone tikzpicture described as below which works well:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{anyfontsize}
\newcommand{\bigfont}{\usefont{T1}{cmr}{m}{n}\fontsize{100}{\baselineskip} \selectfont}
\begin{document}

\begin{tikzpicture}
\draw [line width=1](-1.5,-1.6) rectangle (1.5,1.6) (1.5,1.6);
\node at ( 0,0) {\bigfont{O}};
\end{tikzpicture}

\end{document}

When run by pdflatex we get the following picture:

enter image description here

I saved the standalone file as FIGG.tex and call it in a book as below:

\documentclass{book}

\usepackage{caption}
\usepackage{tikz}
\usepackage{standalone}
\usepackage{biblatex}
\usepackage{filecontents}
\usepackage{mdframed}
\mdfdefinestyle{exampledefault}{linewidth=1pt}
\usepackage{amsthm}
\theoremstyle{definition}
\newtheorem{my_TEXT}{TEXT}

\begin{document}
\begin{mdframed}[style=exampledefault]
\begin{my_TEXT}\textbf{[NICE]}
\begin{center}
\includestandalone[width=.5\textwidth]{FIGG}
\captionof{figure}{MY FIGURE}
\end{center}
\end{my_TEXT}
\end{mdframed}
\end{document}

However this main tex file does not like to show the figure giving me an error:

10 Undefined control sequence. l.10 \node at ( 0,0) {\bigfont {O}}; Do you know how to fix this to be able to call the FIGG in the main tex file?

1 Answer 1

2

In your example, standalone's default setting mode=tex takes effect. Under this mode, \includestandalone works like \input so the file FIGG.tex is included, with its preamble skipped. Therefore the \bigfont defined in the preamble FIGG.tex is skipped, throwing error Undefined control sequence ... \bigfont.

There are two kinds of solutions:

  • If you want to include FIGG as a source file, Then use \usepackage[subpreambles]{standalone} in the main tex file and compile it twice.
  • If you want to insert FIGG as an image, then use modes like buildmissing or buildnew as in \usepackage[mode=<mode>]{standalone} (need -shell-escape) in the main tex file. Check the doc of standalone to see which mode best fits your need.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .