I'm trying to set some figure files in standalone .tex files, and then input them in the main file. Those files looks something like this
\ifx \plotwidth \undefined
\newlength{\plotwidth} \setlength{\plotwidth}{0.9\linewidth}
\else \fi% width of the total figure
\rule{\linewidth}{\plotwidth}% figure goes here
The main idea I have is to set standard widths using \linewidth
, and being able to change the size in the main file by defining the \plotwidth
before inputting the file. However, when I call the figures the second time in the same file, for some reason the \plotwidth
is defined but its lenght is zero. As this example show
\documentclass{article}
\begin{document}
\begin{figure}
\input{fig.tex}
\caption{Test}
\end{figure}
\begin{figure}
\input{fig.tex}
\caption{Test}
\end{figure}
\end{document}
Can someone explain me why this is not working, and how to solve it?