I am suffering from a "TeX capacity exceeded, sorry [save size=50000]" error.

From similar questions (1, 2, 3, 4), I know one fix is to edit a file called "texmf.cnf" and change the "save_size" parameter to something larger.

Unfortunately I have a LyX installation and I can't seem to find this file anywhere on my hard disk.

I do however find a file "texmfapp" (under C:\Program Files (x86)\MiKTeX 2.9\miktex). But this file doesn't have a "save_size" parameter I can change. I reproduce the contents of this file in full below (perhaps there is something here I should change?):

;;; Written in 2016 by Christian Schenk
;;; To the extent possible under law, the author(s) have dedicated all
;;; copyright and related and neighboring rights to this file to the
;;; public domain worldwide.  This file is distributed without any
;;; warranty.  You should have received a copy of the CC0 Public
;;; Domain Dedication along with this file.  If not, see
;;; http://creativecommons.org/publicdomain/zero/1.0/.

;; TeX uses the buffer to contain input lines, but macro
;; expansion works by writing material into the buffer and reparsing the
;; line.  As a consequence, certain constructs require the buffer to be
;; very large, even though most documents can be handled with a small value.

;; Width of context lines on terminal error messages.

;; Extra low memory for boxes, glue, breakpoints, etc.

;; Extra high memory for chars, tokens, etc.

;; Width of first lines of contexts in terminal error messages;
;; should be between 30 and (error_line - 15).

;; Words of inimemory available.

;; Width of longest text lines output; should be at least 60.

;; Maximum number of strings.

;; Maximum number of simultaneous macro parameters.

;; Pool space free after format loaded.

;; Max number of characters in all strings, including all
;; error messages, help texts, font names, control sequences.
;; These values apply to TeX and MP.

;; Maximum number of simultaneous input sources.

;; Strings available after format loaded.

;; 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.

;; Create auxiliary directory if '--aux-directory=DIR' refers
;; a non-existing directory.

;; Create output directory if '--output-directory=DIR' refers
;; a non-existing directory.
  • 3
    Before changing configuration files, you should make sure the error isn't caused by wrong code. So first compile your document manually using pdflatex myfile.tex -save-size=75000 or with even higher values. If you run into the same error, please prepare a minimal example document that reproduces the error and add it to your question
    – siracusa
    Commented Aug 22, 2018 at 1:46
  • @siracusa: I don't think it's caused by wrong code. I have a very large file (the output PDF is about 2,000 pages). When the error occurs (and it seems to do so randomly), I restart LyX and reopen the file and then usually the error then goes away (without my having edited the file at all). I am unable to create a MWE because the error seems to be random.
    – user158988
    Commented Aug 22, 2018 at 2:49
  • 1
    Can you reproduce the error with manual compilation? From your comment it's also possible that LyX creates an incorrect LaTeX file because of the document size, which then produces the error in the compiler. It's hard to help here without knowing where/in what situations the error actually occurs
    – siracusa
    Commented Aug 22, 2018 at 3:43

2 Answers 2


I was unable to find the file called "texmf.cnf".

But the following worked for me:

  1. Go to Tools > Preferences > File Handling > Converters.
  2. Select "LaTeX (pdflatex) -> PDF (pdflatex)".†
  3. Under "Converter:", it should read something like pdflatex $$i. Add to the end of that "-save-size=75000", so that it reads pdflatex $$i -save-size=75000 (or whatever higher value as is necessary).

†Or whatever your default output PDF format happens to be. (You can see this under Tools > Preferences > File Handling > File Formats.")


This error usually is a result of an error in the LaTeX code. Even if you are using LyX, the code produced by LyX may have an error. Either because you added »evil red text«, or you wrote something into the preamble, which is unfortunately somehow wrong, or LyX understood something wrong.

To find out, please export the file to a *.tex file and run it. The log will probably give a better clue where to search.

However, to start hacking into the depth of your TeX-system usually isn't the shortest way to remove the error.

On the other hand it is a good way to learn much more about it :-)

YES, I noticed that you think that fiddling with your TeX-sytem solved the issue. If this were the case, it would be an exception, really.

You must log in to answer this question.