LyXLyx: TeX capacity exceeded

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
MirkoMedia
Posts: 3
Joined: Sat Apr 25, 2020 5:29 am

Lyx: TeX capacity exceeded

Post by MirkoMedia »

Hi,

I am compiling a large document and which cannot be exported from lyx document to pdf any more.

The error which shows up is "TeX capacity exceeded, sorry [main memory size=5000000]"

I was trying out to change the latex options in lyx but they always were ignored. So I do not know how to proceed.

Maybe you have an idea.

Thanks for the comments.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Lyx: TeX capacity exceeded

Post by Ijon Tichy »

I do not use LyX and without any knowledge about your document and when the error message occured first it is very hard so say anything useful about your problem and a solution.

Main memory is used to hold all macro definitions and the current vertical list. It can only exceed if all valid definitions (this is the LaTeX format + the class + packages + preamble definitions etc.) and a single page or a single paragraph (if does not fit on the current page) needs more than the current setting for main memory. 5 Mio words is a lot of main memory, so with a usual document this never happens. But, e.g., with package pdfplots this indeed can happen, because a plot can consist of several millions of single pixels and each of them needs about a dozend words of main memory. The best suggestion for users of pgfplots is not to use PDFLaTeX or XeLaTeX but LuaLaTeX.

In most other cases exceeded main memory is an indication of a mistake of either a package author or the user. For example

Code: Select all

% WARNING: Don't try this using LuaLaTeX, because it will fill all RAM and swap memory of your computer so it becomes unusable!
\documentclass{article}

\usepackage{blindtext}

\newcommand*{\wam}{\blindtext \wam}

\begin{document}
\wam
\end{document}
will result in such an error very fast, because of the infinite loop, which results in an endless paragraph.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
MirkoMedia
Posts: 3
Joined: Sat Apr 25, 2020 5:29 am

Lyx: TeX capacity exceeded

Post by MirkoMedia »

Dear Ijon,

Thanks for the hint. It was indeed a problem with a macro in lyx. I defined \ht but this was already defined, so I renamed it. Since there are so many errors and warnings which I do not understand properly it is very difficult to find out what was going on.

Many error messages are not really self explanatory that's why they accumulated over time :D
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Lyx: TeX capacity exceeded

Post by Ijon Tichy »

Error messages should never accumulate over the time, because each error is serious and should be solved immediately before continuing with the document.

And the LaTeX error message for already defined commands is self explaining:

Code: Select all

\newcommand{\ht}{foo}
results in:
./test.tex:1: LaTeX Error: Command \ht already defined.
Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.1 \newcommand{\ht}{foo}

Moreover the redefinition will be ignored. So it can become dangerous mainly, if someone does not use the high level command \newcommand that should be used to define a new command, but the low-level TeX primitive \def that should not be used to define a new command, even less by someone, who does not know, what he/she/it is doing.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
MirkoMedia
Posts: 3
Joined: Sat Apr 25, 2020 5:29 am

Lyx: TeX capacity exceeded

Post by MirkoMedia »

The low level command comes from Lyx itself:

\global\long\def\htjets{H_{\mathrm{T}}}%

Is used if one adds a macro via the lyx GUI. This solution may not be ideal.
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Lyx: TeX capacity exceeded

Post by Ijon Tichy »

The shown command does not define \ht but \htjets. And indeed (in the document preamble) this should not be done using \long\def but \newcommand. If really LyX does this itself, this is one more reason for me, not to use it. However I cannot reproduce this with LyX. In a minimal document, it does not add such a definition.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply