开发者

How to prevent latex memory overflow

I've got a latex macro that makes small pictures. In that picture I need to draw area. Borders of that area are quadratic bezier curves and that area is to be filled. I did not know how to do it so currently I'm "filling" the area by drawing a plenty of bezier curves inside it...

This slows down typeseting and when a macro is used multiple times (so tex is drawing really a lot of quadratic bezier curves) it produces following error:

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

How can I prevent this error ? (by freeing memory after macro or such...) Or even better h开发者_C百科ow do I fill the area determined by two quadratic bezier curves?

Code that produces error:

\usepackage{forloop}
\usepackage{picture}
\usepackage{eepic}
...
\linethickness{\lineThickness\unitlength}%
\forloop[\lineThickness]{cy}{\cymin}{\value{cy} < \cymax}{%
  \qbezier(\ax, \ay)(\cx, \value{cy})(\bx, \by)%
}%

Here are some example values for variables:

\setlength{\unitlength}{0.01pt}
\lineThickness=20
%cy is just a counter - inital value is not important
\cymin=450 \cymax=900
%from following only the difference between \ax and \bx is important
\ax=0 \ay=0 \bx=550 \by=0

Note: To reproduce the error this code have to execute approximately 150 times (could be more depending on your latex memory settings).

Thanks a lot for any help


I admit I don't know how to manage LaTeX's memory. However, there are better drawing frameworks for LaTeX than the old picture environment, that doesn't seem to support filled bezier paths. Two that comes to mind are the modern-style PGF and Tikz (see also examples) and the more ancient Metapost.


For historical reasons the memory available to TeX lives in a static pool where the size of the allocation is hard coded. You can recompile TeX with this set to a larger size, and some versions allow it to be configured at runtime. This FAQ entry discusses it in a bit more detail.

This page discusses configuring memory in MikTeX. Depending on which distro you're using the details will vary but something similar can be done on most modern TeX distros. Some older ones may require you to modify the source.


It seems to me that my question does not have simple and all solving answer. Using more advanced picture drawing package as Little Bobby Tables suggested caused latex to be able to draw more pictures with some memory size(+- 2 times more) but when drawing more than that the error still occurs.

Enlarging the memory as ConcernedOfTunbridgeWells suggested and then recompiling is something I wanted to avoid. It has also same problem as Little Bobby's suggestion: you can enlarge it 100 times but when typesetting 100 times longer document it will not be sufficient again.

The solution would be to rewrite latex completely as I find this only one of more problems that makes it insufficient for my purposes or use some better typesetting engine(any ideas ?). As I find this too hard I'll be forced to just enlarge memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜