I tried to search a bit, but i guess my poor English prevented me from finding the answer.
I made a few tikz pictures that i want to use in my report. I made the tikz pictures in separate tex files so i don't have to compile my whole report just to check the image.
But now, when copy pasting the tikz code into my report the image looks different. Some stuff moved or is not in the right position.
I was hoping this could be fixed by instead of putting the tikz code in my report, inserting the tikz.tex file similar to \include
or \insert
.
This way i hope my picture will look like it does in the separate file and i will not have to compile it when i compile my report.
I guess this is possible, but i just don't know how and i could not find it. Does anyone know_
Best Answer
Your problem of different results is most likely due to different font sizes or other settings in the picture and main file. This is especially true if you are using
em
orex
as placing units. I can't tell more about it without knowing your code.However, you can avoid this by ensuring identical settings in both files. Should this not be possible you can still compile the external picture to a PDF an include it using
\includegraphics
. There is a small size overhead coming with it, but it should not be an issue. It has actually a nice speed benefit with larger TikZ pictures.For external TikZ pictures I recommend the following procedure: Use the
standalone
class for the TikZ picture file and then use thestandalone
package in the main file. This way you can use\input
to read the external file while its preamble is ignored or even copied to the main preamble automatically. When the external picture is compiled by its ownstandalone
makes sure it is placed on a tight page using thepreview
package. The resulting PDF pictures are very suitable to be included into the main document. I'm currently working on a new version ofstandalone
which gives you an\includestandalone
with an option if the.tex
or.pdf
should be included!Update Apr 2012:
The v1.0 of the
standalone
package now provides\includestandalone
which works like\includegraphics
, but withstandalone
files (and similar). The package has amode=<mode>
option which controls if the standalone source file is compiled with the main document (mode=tex
) or a PDF version is included as image (mode=image
). The PDF can also be build if required (mode=build
,mode=buildnew
ormode=buildmissing
).An important option for this question is
obeyclassoptions
, which will try to obey all class option used in the standalone file even if this file is compiled as part of the main document and therefore the standalone preamble is ignored. This means if the external files use\documentclass[12pt]{standalone}
then a 12pt font size is also used when this file is included (as source code) in the main document.