I am trying to do cirkuittikz diagram inside a subfile but if i compile main it does not work.
main:
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{standalone}
\usepackage{circuitikz}
\usepackage{subfiles}
\begin{document}
\subfile{include/chapter1}
\end{document}
chapter1.tex:
\documentclass[../main.tex]{subfiles}
\begin{document}
\chapter{Test}
\begin{figure}
\centering
\includestandalone{figure/fig}
\caption{A figure.}
\label{fig:fig}
\end{figure}
\end{document}
fig.tex:
\documentclass[12pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw[] (0,0)
to[R]++(0,3)
;
\end{circuitikz}
\end{document}
LaTeX Error: Can be used only in preamble.
You have used a command in the main body of your document which should be used in the preamble. Make sure that \documentclass[…]{…} and all \usepackage{…} commands are written before \begin{document}. Learn more
See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...
l.2 \usepackage {circuitikz} Your command was ignored. Type I to replace it with another command, or to continue without it.
) File: figure/fig.tex Graphic file (type tex) ) (/compile/include/chapter2.tex [1
\input{figure/fig}
.