I am working on a LaTeX file with many plots containing a lot of data points. I have a main.tex file that is including chapter files and inside these chapter files I include the files that contain the \begin{figure}\begin{tikzpicture}...\end{tikzpicture}\end{figure} and I am running into this error

! TeX capacity exceeded, sorry [main memory size=5000000]

I have read many posts about externalizing etc. but I don't know how to apply this method or to put it into other words it is too complicated for me. I simply want to increase my main memory such that I do not run into such problems.

I would be glad if someone could explain to me how I can increase my main memory. I am not looking for a solution with externalization because it is too complicated for me. I am running Texmaker 4.5 as Editor, Miktex 2.9 and Windows 7.

EDIT: What I have tried

  • Finding: texmf.cnf (could not find it using the hint by Alan Munn)
  • Typing: "initexmf --edit-config-file=pdflatex" into the cmd. The pdflatex.ini file opend and I added the following to the file and saved and recompiled without success.




  • 3
  • 3
    Try kpsewhich texmf.cnf in a command line window.
    – Alan Munn
    Nov 24, 2017 at 22:51
  • 1
    Yes a cmd window. Just type exactly that. This is a command that should show you where TeX will look for texmf.cnf. It should return a full path.
    – Alan Munn
    Nov 24, 2017 at 22:54
  • 1
    Sorry, MikTeX seems to work differently from TeX Live. See docs.miktex.org/manual/runtimeparams.html
    – Alan Munn
    Nov 24, 2017 at 23:01
  • 2
    Are you using pgfplots? If so, the best strategy might be to use \usetikzlibrary{external}. This will do away with the need to recompile every plot every time. Compilation will be faster and use less memory. To get around the current memory shortage snag, start with a smaller document: insert \end{document} halfway down or so to compile some plots first, then remove it again and compile the rest. Nov 24, 2017 at 23:05

1 Answer 1


I solved the problem by finally beeing able to use tikz externalize (Miktex 2.9, Editor: Texmaker 4.5, OS: Windows 7).

I used

\usepackage{epstopdf} % to turn my eps files into pdf



My main.tex included my chapters and my plots are included as .tex files into the chapter files. You might have to uncomment plots such that the compilation can start.

Then I open cmd (Windows + R >> cmd) and entered my folder by using cd.. and cd Directory and then I finally used pdflatex -shell-escape main. I have not found a solution for doing this directly from Texmaker 4.5.

  • 1
    Go to Options -> Configure Texmaker in the menu. There, you will see the command template for running pdflatex. Add -shell-escape to it (and remove -synctex=1 if you don't use it). After that, it should work. Nov 26, 2017 at 13:52
  • 1
  • 1
    Please look here - tex.stackexchange.com/questions/236641/shell-escape-in-texmaker. The accepted answer uses --enable-write18 instead of -shell-escape. Maybe that will do it. (I am on Linux, so things are a bit different - didn't mean to give you the run-around.) Nov 26, 2017 at 14:19
  • 1
    Have you tried again to do it stepwise? On the first run, the externalize wouldn't make a difference, so you might have to add the plots one by one. If that does not work, I'm out of ideas ... Nov 26, 2017 at 14:48
  • 1
    A possible workaround may be to use arara to configure your compilation. Texmaker doesn't have a preconfigured command for it, but you could abuse one of the others that you never use (for example, put arara %.tex into the configuration for latexmk). Nov 26, 2017 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.