How to Increase the TeX Input Buffer for pdfLaTeX or LuaLaTeX
At a glance
- 1. Check the error
Confirm that the message is about the input buffer, not a different TeX capacity limit.
- 2. Find the active setting
Use kpsewhich to locate texmf.cnf and check the effective buf_size value.
- 3. Change it locally
Set buf_size in a writable configuration file, rather than editing a file managed by your TeX distribution.
- 4. Test both engines
Restart compilation and verify the setting and the document with the engine that produced the error.
The TeX input buffer limits how many characters the engine can hold while reading an input line. If a physical line in a .tex file or a file it reads is too long, TeX may report a capacity error naming the input buffer, such as “TeX capacity exceeded, sorry [input buffer size=…].” You can raise the buf_size setting in Web2C-based TeX installations, including many TeX Live setups, but first check that this is actually the limit you have hit.
Check which limit the error refers to
buf_size is about the length of an input line, not the total number of characters in your document. A large document made of ordinary lines does not, by itself, require a larger input buffer. A generated file with a single very long line, however, might.
TeX has other capacity limits. For example, “input stack size” points to a nesting or input-stack issue, not a long-line problem. Increasing buf_size will not fix every message that begins “TeX capacity exceeded.” Read the specific limit named in the error before changing configuration.
If you control the source, splitting a very long line into shorter lines is often simpler and more portable than changing engine settings. Check generated .tex files too: tables, data exports, and automatically produced macros may contain the long line even when your main document does not.
Find and change buf_size
In a Web2C-based installation, texmf.cnf contains engine configuration variables. Use kpsewhich to see which configuration files are available and what value is effective:
kpsewhich -a texmf.cnf
kpsewhich -var-value=buf_size
The available file locations and configuration rules vary by TeX distribution and operating system. Prefer a writable local or user configuration file recognized by your installation. Avoid changing a file managed by the distribution: updates may overwrite it, and you may not have permission to edit it. The kpsewhich -a output can help you find the active files; consult your distribution’s documentation for the correct location and precedence rules.
Add or adjust the setting in the appropriate configuration file, for example:
buf_size = 500000
Use a value large enough for the longest line, with some margin. Don’t assume that 500000 is right for every document, or that every engine build allows every value. After saving the change, run kpsewhich -var-value=buf_size again. If it still reports the old value or nothing useful, the file you edited may not be read, or another configuration setting may take precedence.
Worked example
Suppose the effective value is 200000, and a generated input file contains a physical line of about 250,000 characters. The current setting is too small for that line. If the installation permits it, setting buf_size = 500000 provides room for the line and some headroom. Check the effective value, then compile the document with the engine that produced the error, such as pdflatex or lualatex.
The example values are illustrative, not universal defaults. TeX distributions and engine builds can differ. If the configuration change is recognized but compilation still fails, check whether the reported limit is really the input buffer, whether the long line is in an included or generated file, and whether your engine has a fixed upper bound.
Do you need to rebuild formats?
Some TeX settings are read when an engine starts; other changes can involve the formats used by LaTeX. The details depend on the engine and distribution. After changing configuration, test compilation first. If the new setting is not taking effect in the LaTeX format you use, follow your distribution’s instructions for rebuilding formats (for example, with its format-generation utility). Do not rebuild every format as a first step unless the distribution’s documentation says it is necessary.
For MiKTeX or another installation that does not use the usual Web2C configuration workflow, use that distribution’s own settings and documentation rather than assuming that editing a TeX Live texmf.cnf will apply.
Common mistakes
- Changing the wrong setting:
buf_sizeconcerns input-line length. It does not increase every TeX capacity. - Measuring the document instead of its longest line: A long file can be fine if each physical line is short.
- Editing a managed configuration file: Updates can replace the change. Use a local configuration mechanism supported by your distribution.
- Assuming both engines use the same configuration in every installation: pdfTeX and LuaTeX often share Web2C configuration conventions, but installation details and limits can vary.
- Ignoring the source of the long line: If a program generates the input, fixing its line wrapping may be more robust than raising the buffer limit.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.