Saving Canvas in Tex awesome! But long compiling time

Two suggestions for Andres:

  1. For very big 2D histograms, pdflatex crashes when compiling. The solution is to use “lualatex” instead. See also Colored 2D histograms in pdf output - #45 by ferhue

  2. In Latex, you can also use “tikzexternal” for not slowing down your compilation time, for example with the mode “list and make”, that saves the temporary pdf images in the subdirectory “build/i/”. This way you separate the translation of the figures to “.pdf” from the actual compilation of your main tex document.

\tikzexternalize[mode=list and make, prefix=i/]

I use TexMaker with the “build” subdirectory option on, and I still use a Makefile for regenerating figures (stored in Figures/ subfolder) if you are modifying them (as tikz only looks if the build/i/.pdf was modified, not the respective Figures/.tex):

ALL_FIGURE_NAMES=$(shell cat build/MyProject.figlist)
ALL_FIGURES=$(ALL_FIGURE_NAMES:%=build/%.pdf)

all: $(ALL_FIGURES)
        
build/i/%.pdf : Figures/%.tex
        pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "$(subst build/i/,i/,$(@:.pdf=))" "\def\tikzexternalrealjob{MyProject}\input{MyProject}" 

clean:
        rm -r build
        mkdir -p build/i

Note that you also need to set a link in your main folder:

ln -s build/i/ i/

And to compile everything at the same time

make && pdflatex -shell-escape -synctex=0 -output-directory=build/ -interaction=nonstopmode MyProject.tex

There might be a cleaner option, but this one works fine.