taco wrote:
Graham Douglas wrote:
Many thanks. What would I need to implement in order to include TeX material in mp code? I guess Hans has written some wizardry for getting this to work in ConTeXt?
Any pointers would be appreciated.
Have a look at the mlib-pps.* files from the context distribution.
The basic approach is to typeset the label using normal TeX-style boxes and to insert a placeholder in the metapost input instead of the actual label. That placeholder is then later replaced by the typeset label during the mp-to-pdf conversion step.
Best wishes, Taco
__________ Information from ESET Smart Security, version of virus signature database 5078 (20100501) __________
The message was checked by ESET Smart Security.
Hi Taco Great, many thanks for the pointers. On another MPlib/MetaPost-related issue + apologies if this is off-topic, but I'm getting out of memory errors with the example below -- some Hilbert curve code I found on the web. The memory settings below are quite large so I'm a bit surprised that this is failing. Are you able to run this example? The line to control this is at the end of the code draw hilbertPath(3.72, 6); Thank you, as ever, for sharing your time and expertise. Best wishes Graham ================== out of memory warning ===================== [This is MetaPost, Version 1.209 ! MetaPost capacity exceeded, sorry [main mem ory size=10000000]. hilbertPath->...f.p101;hilb:=p100&P100--P101&p101; P102:=P101shifted((vs+0.5v... <*> ... 0, hoehe)--cycle; draw hilbertPath(3.72, 6) ; endfig; bye =================== code example ======================== local function finder(name, mode, ftype) local found if mode=="w" then found = name else found = kpse.find_file(name,ftype) end if found then print("MPlib finder: " .. name .. " -> " .. found) end return found end mp = mplib.new ( { hash_size = 10000000, main_memory = 10000000, param_size = 10000000, ini_version=false, mem_name=plain, find_file = finder, } ) if mp then res=mp:execute("u:=25; % 25 = 25bp = 25 PostP102cript points = 25/72 in wi:=10; % width in units u he:=10; % height in units u hoehe:=he*u; % height breite:=wi*u; % width path p[]; pair P[], versch, vs; P0:=(6.875, hoehe-6.875); % starting point top left vardef hilbertPath(expr s, n) = % % recursively calculates and returns path ``hilb'' % of segment length s and depth n % pair versch; path hilb, hilbOLD; versch:=(s, 0); % --- Calculation of path ``hilb'' --- if n=0: hilb:=P0; else: hilbOLD:=hilbertPath(s, n-1); p100:=hilbOLD reflectedabout(P0, P0 shifted (1, -1)); P100:=point length(p100) of p100; vs:=P100-P0; p101:=hilbOLD shifted (vs+versch); P101:=point 0 of p101; hilb:=p100&P100--P101&p101; P102:=P101 shifted ((vs+.5versch) rotated -90); p102:=reverse hilb reflectedabout(P102, P102 shifted (1,0)); hilb:=hilb&point length(hilb) of hilb--point 0 of p102&p102; fi % --- End: Calculation of path ``hilb'' --- hilb % return path ``hilb'' enddef; beginfig(1) draw (0, 0)--(breite, 0)--(breite, hoehe)--(0, hoehe)--cycle; draw hilbertPath(3.72, 6); % Draw Hilbert curve of segment length % 3.72 PostScript points and depth 6 % draw hilbertPath(2, 7); % maximum possible depth % with main memory size=1000001 endfig; bye")