This answer describes how to include a tikz
file in your document, whether it is an article, a book or a beamer presentation.
It works fine, up until the point that you call for some other libraries.
Suppose I have the following graphics:
% File myDrawing.tex
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{math} %needed tikz library
\tikzmath{\x1 = 1; \y1 =1; \x2 = \x1 + 1; \y2 =\y1 +3; }
% Using the variables for drawing
\begin{tikzpicture}
\draw[very thick, -stealth] (\x1, \y1)--(\x2, \y2);
\end{tikzpicture}
\end{document}
As you can see it consists of mainly a tikzpicture
environment, but it also calls for the math
tikz library, and declares variables \x1
and \y1
outside the tikzpicture environment.
As yet another example, consider this pgfplots
part of code:
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows.meta}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot { .... };
\end{axis}
\end{tikzpicture}
\end{document}
It makes use of the arrows
library and sets the pgfplots version, outside the tikzpicture environment, too.
Is it possible to create a file myDrawing.tikz
that I can transplant in my main document, and also make use of the tikzscale
package? If the answer is yes, then how? Can you post an example?
I am having difficulties with correctly and nicely (in)putting a drawing inside my document. Particularly with the height-to-width aspect ratio.
Until now I saved the drawing as a tex
file, under a standalone
document class and worked with includestandalone[width=...]{path/to/file}
as described here. But sometimes I want the figure to be inside a \begin{columns} \column{0.4\textwidth} \end{columns}
environment in a beamer presentation, and sometimes in the side margin of a book document, with a width=\marginparwidth
option.
The tikzscale package looks very promising, but its documentation instructs its use only when working with tikz
files.