7

I have a LaTeX document that uses many long pgf paths, and thus compiles only if one increases the TeX "capacity" by setting save_size=50000 in texmf.cnf.

Unfortunately I cannot change the system-wide texmf.cnf directly as I have no root access on my work machine (OpenSuSE 11.3). Is there a way to use a user-defined texmf.cnf that overrides the limits?

Disclaimer: as pointed out by Juan Navarro in the comments, errors of the form tex capacity exceeded are often caused by syntax errors. Even if you get that error message, 99% of the times the correct thing to do is not increasing capacity.

  • 3
    Maybe for some reason you really need to do this but, in my experience, you hardly ever need to "increase LaTeX capacity"; often this just means that there is an error on your .tex file that you should try to solve. Comment out portions of your code until it works, and try to determine what causes the "LaTeX capacity exceeded" error. – Juan A. Navarro Sep 05 '11 at 08:48
  • 1
    I think I do need to increase LaTeX capacity. On a computer on which I do have root access, my document compiles if I set save_size = 50000 rather than 5000. I am including a pgf path with some 200 points with \input{} multiple times --- or maybe is there a smarter way to do that? – Federico Poloni Sep 05 '11 at 08:57
  • @Federico, this is another question... – pmav99 Sep 05 '11 at 10:13
  • Ok, but I don't think that's the main point - let's say that the question is 'I have some odd latex file that compiles only if I set save_size=50000 --- but alas, I am not root. How can I make this change?' – Federico Poloni Sep 05 '11 at 11:26
  • 1
    I see a -save-size=N option in my pdflatex command (MiKTeX 2.9). Does that help? – Paulo Cereda Sep 05 '11 at 11:46
  • On my distro (texlive 2009) this command-line switch has no effect (the document still fails to compile and complains that save_size=5000 is not enough), and it is not mentioned in the docs either. – Federico Poloni Sep 05 '11 at 11:57
  • 2
    @Federico, Indeed you might then need to do this. I only wanted to add that disclaimer for people stumbling with this question while googling how to "increase LaTeX capacity". – Juan A. Navarro Sep 05 '11 at 15:46
  • 2
    You can increase the memory size locally by editing a local texmf.cnf. The trick is that you need to regenerate the formats using fmtutil after changing the sizes. This answer Memory settings with MacTeX outlines the steps for doing this with root access; you can follow the same steps for modifying a local texmf.cnf provided you use fmtutil instead of fmutil-sys. – Alan Munn Sep 05 '11 at 16:17
  • @Alan I'm not really sure if it's necessary to always regenerate the formats using fmtutil after changing the sizes. If you read the part 3 of texmf.cnf, you can find "If a change here appears to be ignored, try redumping the format file with fmtutil-sys" and "main_memory is relevant only to initex, extra_mem_* only to non-ini. Thus, have to redump the .fmt file after changing main_memory; to add to existing fmt files, increase extra_mem_* ". What do you think about theses sentences ? – Alain Matthes Sep 05 '11 at 17:12
  • @Altermundus I seem to recall during my testing of the answer I referenced, that running fmtutil was necessary. This seems to be confirmed also by this question Why is TeX ignoring texmf.cnf?. But since this is something that most of us do very rarely, if at all, there may well be details that I've overlooked. I don't think that regenerating the formats will cause any problems otherwise. The only issue is that any updates that require rebuilding formats in the root version won't be reflected with a locally built set of formats. – Alan Munn Sep 05 '11 at 17:19
  • @Alan Yes I read the link but I'm not really sure because when I compile the pgfmanual, I use the Makefile of the sources and this file uses a texmf.cnf local. A lot of sizes are changed and I don't regenerate the fmt. It will be interesting to know exactly what we need to do and in which case. – Alain Matthes Sep 05 '11 at 17:25

1 Answers1

15

I had the same requirement when I worked with pgfplots - and I found a way.

The resulting steps have made their way into the pgfplots manual, compare the pdf at http://pgfplots.sourceforge.net/

For your convenience, I post a copy of the section about TeX-Live here, it will probably answer your question:

6.2.2 TEXLive or similar installations For Unix installations, one needs to adjust config files. This can be done as follows:

  1. Locate texmf.cnf on your system. On my Ubuntu installation, it is in /usr/share/texmf/web2c/texmf.cnf.

  2. Either change texmf.cnf directly, or copy it to some convenient place. If you copy it, here is how to proceed:

    keep only the changed entries in your local copy to reduce conflicts. TEX will always read all config files found in its search path.

    Adjust the search path to find your local copy. This can be done using the environment variable TEXMFCNF. Assuming your local copy is in~/texmf/mytexcnf/texmf.cnf, you can write

        `export TEXMFCNF=~/texmf/mytexcnf:`
    

    to search first in your directory, then in all other system directories.

  3. You should change the entries


       main_memory = n
       extra_mem_top = n
       extra_mem_bot = n
       max_strings = n
       param_size = n
       save_size = n
       stack_size = n

The log­file usually contains information about the parameter which needs to be enlarged.

An example of this config file thing is shown below. It changes memory limits.

  1. Create the file ~/texmf/mytexcnf/texmf.cnf (and possibly the paths as well).

       % newly created file ~/texmf/mytexcnf/texmf.cnf:
       % If you want to change some of these sizes only for a certain TeX
       % variant, the usual dot notation works, e.g.,
       % main_memory.hugetex = 20000000
       main_memory = 230000000 % words of inimemory available; also applies to inimf&mp
       extra_mem_top = 10000000      % extra high memory for chars, tokens, etc.
       extra_mem_bot = 10000000      % extra low memory for boxes, glue, breakpoints, etc.
       save_size = 150000     % for saving values outside current group
       stack_size = 150000      % simultaneous input sources
       %  Max number of characters in all strings, including all error messages,
       %  help texts, font names, control sequences. These values apply to TeX and MP.
       % pool_size = 1250000
       %  Minimum pool space after TeX/MP's own strings; must be at least
       %  25000 less than pool_size, but doesn't need to be nearly that large.
       % string_vacancies = 90000
       %  Maximum number of strings.
       % max_strings = 100000
       %  min pool space left after loading .fmt
       % pool_free = 47500
  1. Run texhash such that TEX updates its ~/texmf/ls-R database.

  2. Create the environment variable TEXMFCNF and assign the value ~/texmf/mytexcnf: (including the trailing : !). For my linux system, this can be done using by adding

    export TEXMFCNF=~/texmf/mytexcnf:

    to ~/.bashrc.

Unfortunately, TEX does not allow arbitrary memory limits, there is an upper bound hard coded in the executables.