# Using \input{standalone_file.tex} and ignore some lines or commands in it

I want to draw my tikz-pictures inside a standalone class. However, for referencing and bib purposes and to make sure all font setting etc. are correct, I then want to compile the picture from the main-file.

However, I am using a precombiled preamble for both, the main file and one preamble for the standalone (btw that makes it possible ro recompile the picture in the standalone within 1-2 seconds).

the standalonefile looks something like this:

%&standalone
\IfFileExists{../../_preamble/check_file.tex}% prüfen aus welcher datei der
aufruf stattfindet
{%
\providecommand{\myPath}{../../}% file exists=true
}%
{%
\providecommand{\myPath}{}% file exists=false
}%

%\input{\myPath_preamble/class_declaration_sa.tex}%% läd standalone-klasse mit tikz-argument
\input{\myPath_preamble/tikz_library.tex}%% diverse tikz-bibliotheken
\input{\myPath_preamble/graphic_packages.tex}%% nur laden wenn weitere graphic pakete benötigt werden (tabellen, pgfplot,...)
\input{\myPath_preamble/pgfplot_library.tex}%% tikz-styles, farben etc.

\endofdump

\input{\myPath_preamble/tikz_styles.tex}%% tikz-styles, farben etc.
\input{\myPath_preamble/pgfplot_styles.tex}%% tikz-styles, farben etc.

\begin{document}%
\IfFileExists{../../_preamble/check_file.tex}% prüfen aus welcher datei der aufruf stattfindet
{%file exists=true: befinde mich im unterverzeichnis
\input{_qtikz_gm_statistik.tex}%
}%
{%file exists=false: befinde mich im root_verzeichnis
\input{_img/_pgfplot/_qtikz_gm_statistik.tex}%\\
}%
\end{document}%


So in the main.tex just using \input{standalone_file} results in an error caused by the used precompiled preamble. To make this work I have to comment in every picture I use several rows:

%&standalone                                       <- have to comment this
\endofdump                                         <- have to comment this
%\input{\myPath_preamble/class_declaration_sa.tex} <- have to uncomment this


When then trying to use the standalone-class again I have to do it the other way round and so on.

So i was thinking if there is a way to automate this by saying something like use input but ignore or modify line-numbers x,y,z so the \input works from th main but still the standalone class itself.

As the 'preamble' is static in each standalone class the line numbers won't change I would say.