I would like to extract images and TikZ diagrams as separate pdf files for each diagram on overleaf. Each output should contain only single image without extra spaces. I could not find an automated solution for this. Currently, I have prepared minimalExport.tex for this purpose as below. If I have modified the documentclass as article, the error is disappeared but it is not what I really need because the image is placed on a paper rather than squeezing the outer rectangle of image. How can I eliminate this error ?
I have also tried other solutions which were commented out on the below code because there was no success. Do you think this method makes sense once you would like to export each diagram as vector file (.pdf) from your latex document ?
%\documentclass{article}
\documentclass{standalone}
%\usepackage{standalone}
%\usepackage[pdftex,active,tightpage]{preview}
%\usepackage[mode=buildnew,subpreambles=true]{standalone}
\usepackage{float, graphicx}
\def\DiagramTemp{
\begin{figure}[h]
\centering
\resizebox{0.7\linewidth}{!}{
\includegraphics{img/overleaf-logo.png}
}
\end{figure}
}
\begin{document}
\DiagramTemp{}
\end{document}
The error output on overleaf:
LaTeX Error: Something's wrong--perhaps a missing \item.
jot-latex-template/minimini.tex, 22
There are no entries found in a list you have created. Make sure you label list entries using the \item command, and that you have not used a list inside a table.
Learn more
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.22 \DiagramTemp
{}
Try typing <return> to proceed.
If that doesn't work, type X <return> to quit.

standalonethere is no\linewidthso you cannot do that. Besides, use the\includegraphics[width=.7\linewidth]{}instead ofadjustboxwhich is more direct. – Teddy van Jerry Mar 24 '22 at 12:57resizebox, and I got exactly the same output, nothing more or less. Thanks for the comment anyway. – ozturkib Mar 24 '22 at 13:00figureenvironment which does not make sense if your intention is to have the graph only. Just\includegraphicswill do, – Teddy van Jerry Mar 24 '22 at 13:02figurehere? In the shown example thefigureenv does nothing (not even sure if it is supported bystandalone) – daleif Mar 24 '22 at 13:19preview. Try it out and see if it works – user202729 Mar 24 '22 at 17:55