views:

179

answers:

3

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 how 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

+2  A: 

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.

Little Bobby Tables
Thanks for tip. I've already writen quite some code so learning new package and rewriting everything seems quite a lot of work for me. I'd prefer another solution.
drasto
Anyway this is the best option I have found so far, so I'm rewriting the whole thing in PGF and Tikz. I consider this the best possible solution for me and the question answered.
drasto
So I was wrong. I've rewritten the whole package in PGF and Tikz and I still get the error. I need to use the macro more times then before, but still, if I draw enough charts I get the same error.
drasto
+2  A: 

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.

ConcernedOfTunbridgeWells
Thanks for tip. I'm sure they will be usefull for me some time or at least for somebody else.
drasto
+1  A: 

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.

drasto