Hi, I don't know if I can explain the problem I'm having. I made a project with 14 chapters. In each of them, there are graphics embedding metapost code. I proceed as follows : I compile each chapter alone with lmtx then I compile the project containing the 14 chapters. I didn't encounter any problems except with a graphic from the last chapter. It is indeed in chapter 14 but not in the project ! I give the code for this graph. Thanks. Fabrice \startMPcode interim linejoin := mitered; interim ahangle := 30; numeric u, pi; pi = 3.141592653589793; u = 1.5cm; vardef graph_of_function (suffix f) (expr xmin, xmax, xsep) = for x = xmin step xsep until xmax: (x, f(x)) .. endfor (xmax, f(xmax)) enddef ; vardef vline (suffix f, g) (expr x) = (x, min(f(x), g(x))) -- (x, max(f(x),g(x))) enddef; vardef area_between_functions (suffix f, g)(expr a, b, xsep) = buildcycle(graph_of_function(f, a, b, xsep), vline(f, g, b), reverse graph_of_function(g, a, b, xsep), reverse vline(f, g, a)) enddef; vardef xaxis (expr xmin, xmax) = (xmin, 0) -- (xmax, 0) enddef ; vardef yaxis (expr ymin, ymax) = (0, ymin) -- (0, ymax) enddef ; xmin:=-pi/2; xmax := 3*pi/2; ymin := -1.5; ymax := 5; vardef f(expr x)= exp(-x)*(-cos(x)+sin(x)+1) enddef; vardef g(expr x)=-exp(-x)*cos(x) enddef; path C_f, C_g; C_f = graph_of_function(f,xmin, xmax, .1); C_g = graph_of_function(g, xmin, xmax, .1); a := xpart(C_f intersectionpoint C_g); b := xpart(reverse C_f intersectionpoint reverse C_g); fill (area_between_functions(f, g, a, b, 0.1)) scaled u withcolor 0.4[white, blue]; draw C_f scaled u withcolor blue; draw C_g scaled u withcolor blue; \stopMPcode
H Fabrice, You did not provide a good minimum test because the graph by itself renders fine: Best wishes, Taco (if all else fails, you can replace \startMPcode with \startMPpage and generate a standalone graph that way)
On 25 Apr 2024, at 12:27, Fabrice Couvreur
wrote: Hi, I don't know if I can explain the problem I'm having. I made a project with 14 chapters. In each of them, there are graphics embedding metapost code. I proceed as follows : I compile each chapter alone with lmtx then I compile the project containing the 14 chapters. I didn't encounter any problems except with a graphic from the last chapter. It is indeed in chapter 14 but not in the project ! I give the code for this graph. Thanks. Fabrice
\startMPcode
interim linejoin := mitered; interim ahangle := 30; numeric u, pi;
pi = 3.141592653589793; u = 1.5cm;
vardef graph_of_function (suffix f) (expr xmin, xmax, xsep) = for x = xmin step xsep until xmax: (x, f(x)) .. endfor (xmax, f(xmax)) enddef ;
vardef vline (suffix f, g) (expr x) = (x, min(f(x), g(x))) -- (x, max(f(x),g(x))) enddef;
vardef area_between_functions (suffix f, g)(expr a, b, xsep) = buildcycle(graph_of_function(f, a, b, xsep), vline(f, g, b), reverse graph_of_function(g, a, b, xsep), reverse vline(f, g, a)) enddef;
vardef xaxis (expr xmin, xmax) = (xmin, 0) -- (xmax, 0) enddef ; vardef yaxis (expr ymin, ymax) = (0, ymin) -- (0, ymax) enddef ;
xmin:=-pi/2; xmax := 3*pi/2; ymin := -1.5; ymax := 5;
vardef f(expr x)= exp(-x)*(-cos(x)+sin(x)+1) enddef; vardef g(expr x)=-exp(-x)*cos(x) enddef; path C_f, C_g; C_f = graph_of_function(f,xmin, xmax, .1); C_g = graph_of_function(g, xmin, xmax, .1);
a := xpart(C_f intersectionpoint C_g); b := xpart(reverse C_f intersectionpoint reverse C_g);
fill (area_between_functions(f, g, a, b, 0.1)) scaled u withcolor 0.4[white, blue]; draw C_f scaled u withcolor blue; draw C_g scaled u withcolor blue;
\stopMPcode ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
— Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
Hi Taco,
I knew I wouldn't be able to explain what was happening.
The code works perfectly and the figure is clearly visible in the component
chapter-14 :
\startcomponent[chapter-14]
\startMPpage
...
\stopMPpage
\stopcomponent
But if I compile my project, it disappears !!
\startproduct[terminale-manual]
\startbodymatter
\component[chapter-1]
\component[chapter-2]
\component[chapter-3]
\component[chapter-4]
\component[chapter-5]
\component[chapter-6]
\component[chapter-7]
\component[chapter-8]
\component[chapter-9]
\component[chapter-10]
\component[chapter-11]
\component[chapter-12]
\component[chapter-13]
\component[chapter-14]
\stopbodymatter
\stopproduct
Le jeu. 25 avr. 2024 à 13:36, Taco Hoekwater
H Fabrice,
You did not provide a good minimum test because the graph by itself renders fine:
Best wishes, Taco (if all else fails, you can replace \startMPcode with \startMPpage and generate a standalone graph that way)
On 25 Apr 2024, at 12:27, Fabrice Couvreur
wrote: Hi, I don't know if I can explain the problem I'm having. I made a project with 14 chapters. In each of them, there are graphics embedding metapost code. I proceed as follows : I compile each chapter alone with lmtx then I compile the project containing the 14 chapters. I didn't encounter any problems except with a graphic from the last chapter. It is indeed in chapter 14 but not in the project ! I give the code for this graph. Thanks. Fabrice
\startMPcode
interim linejoin := mitered; interim ahangle := 30; numeric u, pi;
pi = 3.141592653589793; u = 1.5cm;
vardef graph_of_function (suffix f) (expr xmin, xmax, xsep) = for x = xmin step xsep until xmax: (x, f(x)) .. endfor (xmax, f(xmax)) enddef ;
vardef vline (suffix f, g) (expr x) = (x, min(f(x), g(x))) -- (x, max(f(x),g(x))) enddef;
vardef area_between_functions (suffix f, g)(expr a, b, xsep) = buildcycle(graph_of_function(f, a, b, xsep), vline(f, g, b), reverse graph_of_function(g, a, b, xsep), reverse vline(f, g, a)) enddef;
vardef xaxis (expr xmin, xmax) = (xmin, 0) -- (xmax, 0) enddef ; vardef yaxis (expr ymin, ymax) = (0, ymin) -- (0, ymax) enddef ;
xmin:=-pi/2; xmax := 3*pi/2; ymin := -1.5; ymax := 5;
vardef f(expr x)= exp(-x)*(-cos(x)+sin(x)+1) enddef; vardef g(expr x)=-exp(-x)*cos(x) enddef; path C_f, C_g; C_f = graph_of_function(f,xmin, xmax, .1); C_g = graph_of_function(g, xmin, xmax, .1);
a := xpart(C_f intersectionpoint C_g); b := xpart(reverse C_f intersectionpoint reverse C_g);
fill (area_between_functions(f, g, a, b, 0.1)) scaled u withcolor 0.4[white, blue]; draw C_f scaled u withcolor blue; draw C_g scaled u withcolor blue;
\stopMPcode
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
— Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
Hi Taco, I knew I wouldn't be able to explain what was happening. The code works perfectly and the figure is clearly visible in the component chapter-14 :
\startcomponent[chapter-14] \startMPpage ... \stopMPpage \stopcomponent
But if I compile my project, it disappears !!
\startproduct[terminale-manual] \startbodymatter \component[chapter-1] \component[chapter-2] \component[chapter-3] \component[chapter-4] \component[chapter-5] \component[chapter-6] \component[chapter-7] \component[chapter-8] \component[chapter-9] \component[chapter-10] \component[chapter-11] \component[chapter-12] \component[chapter-13] \component[chapter-14] \stopbodymatter \stopproduct -- compile with specific preceding chapters commented -- when the interfering one is found, make a copy and strip till the
On 4/25/2024 4:08 PM, Fabrice Couvreur wrote: problem is gone it might be that you redefine something metapost Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 25 Apr 2024, at 16:08, Fabrice Couvreur
wrote: Hi Taco, I knew I wouldn't be able to explain what was happening. The code works perfectly and the figure is clearly visible in the component chapter-14 :
It is probably not related to the figure itself. Something may be different in this component compared to the other ones. I cannot really say, of course. Still, using external image instead of inline metapost may be fix it. Not elegant, but if it works it works! Good luck, Taco
\startcomponent[chapter-14] \startMPpage ... \stopMPpage \stopcomponent
But if I compile my project, it disappears !!
\startproduct[terminale-manual] \startbodymatter \component[chapter-1] \component[chapter-2] \component[chapter-3] \component[chapter-4] \component[chapter-5] \component[chapter-6] \component[chapter-7] \component[chapter-8] \component[chapter-9] \component[chapter-10] \component[chapter-11] \component[chapter-12] \component[chapter-13] \component[chapter-14] \stopbodymatter \stopproduct
— Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
Hi Hans and Taco,
@Hans, I compiled by commenting and uncommenting one component at a time;
it is component 5 which interferes with the metapost code of component 14
All I have to do now is find out what the cause is.
Fabrice
Le jeu. 25 avr. 2024 à 16:40, Taco Hoekwater
On 25 Apr 2024, at 16:08, Fabrice Couvreur
wrote: Hi Taco, I knew I wouldn't be able to explain what was happening. The code works perfectly and the figure is clearly visible in the component chapter-14 :
It is probably not related to the figure itself. Something may be different in this component compared to the other ones. I cannot really say, of course. Still, using external image instead of inline metapost may be fix it. Not elegant, but if it works it works!
Good luck, Taco
\startcomponent[chapter-14] \startMPpage ... \stopMPpage \stopcomponent
But if I compile my project, it disappears !!
\startproduct[terminale-manual] \startbodymatter \component[chapter-1] \component[chapter-2] \component[chapter-3] \component[chapter-4] \component[chapter-5] \component[chapter-6] \component[chapter-7] \component[chapter-8] \component[chapter-9] \component[chapter-10] \component[chapter-11] \component[chapter-12] \component[chapter-13] \component[chapter-14] \stopbodymatter \stopproduct
— Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
Hi,
Here is the code that interferes with the graph from the last chapter but
why ?
\startMPcode
pickup pencircle xscaled 1;
defaultfont := "texgyrepagella-regular*default" ;
defaultscale := 0.8 ;
path circle, p, q, b;
circle = fullcircle xscaled 5cm yscaled 3.5cm;
p = (point 2 of circle .. (-0.15cm,1.5cm)
..(0,0)..(0.15cm,-1.5cm).. point 6 of circle);
q = (subpath(0,2) of circle -- p -- subpath(6,8) of circle
--cycle);
b = (reverse p -- subpath(2,6) of circle -- cycle);
definecolor [ name = "mp:red", r = 1 ];
definecolor [ name = "mp:blue", r = 0.54, g = 0.17, b = 0.89 ];
fill q withcolor "mp:red" withtransparency(1,0.4) ;
fill b withcolor "mp:blue" withtransparency(1,0.4) ;
draw circle;
draw p;
label("$\overline{\text{A}}$",( 1.5cm,0));
label("$\text{A}$",(-1.5cm,0));
label.top("E",(0,1.85cm));
\stopMPcode
Le jeu. 25 avr. 2024 à 16:55, Fabrice Couvreur
Hi Hans and Taco, @Hans, I compiled by commenting and uncommenting one component at a time; it is component 5 which interferes with the metapost code of component 14 All I have to do now is find out what the cause is. Fabrice
Le jeu. 25 avr. 2024 à 16:40, Taco Hoekwater
a écrit : On 25 Apr 2024, at 16:08, Fabrice Couvreur
wrote: Hi Taco, I knew I wouldn't be able to explain what was happening. The code works perfectly and the figure is clearly visible in the component chapter-14 :
It is probably not related to the figure itself. Something may be different in this component compared to the other ones. I cannot really say, of course. Still, using external image instead of inline metapost may be fix it. Not elegant, but if it works it works!
Good luck, Taco
\startcomponent[chapter-14] \startMPpage ... \stopMPpage \stopcomponent
But if I compile my project, it disappears !!
\startproduct[terminale-manual] \startbodymatter \component[chapter-1] \component[chapter-2] \component[chapter-3] \component[chapter-4] \component[chapter-5] \component[chapter-6] \component[chapter-7] \component[chapter-8] \component[chapter-9] \component[chapter-10] \component[chapter-11] \component[chapter-12] \component[chapter-13] \component[chapter-14] \stopbodymatter \stopproduct
— Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
On 25 Apr 2024, at 23:12, Fabrice Couvreur
wrote: Hi, Here is the code that interferes with the graph from the last chapter but why ?
Because of this “path b”:
path circle, p, q, b;
which interferes with the assignment line from the other graphic code:
b := xpart(reverse C_f intersectionpoint reverse C_g);
because there “b” is a now a path, not a numeric. Adding numeric a,b; fixes the problem in chapter 14. But why it does not affect chapters 6-13, that I do not understand. — Taco Hoekwater E: taco@bittext.nl genderfluid (all pronouns)
On Fri, 26 Apr 2024, Taco Hoekwater wrote:
On 25 Apr 2024, at 23:12, Fabrice Couvreur
wrote: Hi, Here is the code that interferes with the graph from the last chapter but why ?
Because of this “path b”:
path circle, p, q, b;
which interferes with the assignment line from the other graphic code:
b := xpart(reverse C_f intersectionpoint reverse C_g);
because there “b” is a now a path, not a numeric.
Adding
numeric a,b;
fixes the problem in chapter 14.
Woundn't newnumeric be better? There are very few instances where I want variables defined in one block to be reused in another block. So, I almost always use \startMPcode begingroup; .... endgroup; \stopMPcode to avoid such issues. Aditya
Hi,
Thanks for your help. I did several tests playing only with the code of
component 5 which interferes with that of component 14.
@Aditya
begingroup;
.....
endgroup;
does not work.
@Hans
save defaultfont, defaultscale;
maybe also:
save circle, p, q, b ;
I get an empty rectangle in place of the graph in composant 5.
@Taco
The solution that works is to add component 14 to the code
numeric a, b;
Fabrice
Le ven. 26 avr. 2024 à 10:45, Aditya Mahajan
On Fri, 26 Apr 2024, Taco Hoekwater wrote:
On 25 Apr 2024, at 23:12, Fabrice Couvreur <
fabrice1.couvreur@gmail.com> wrote:
Hi, Here is the code that interferes with the graph from the last chapter
but why ?
Because of this “path b”:
path circle, p, q, b;
which interferes with the assignment line from the other graphic code:
b := xpart(reverse C_f intersectionpoint reverse C_g);
because there “b” is a now a path, not a numeric.
Adding
numeric a,b;
fixes the problem in chapter 14.
Woundn't newnumeric be better?
There are very few instances where I want variables defined in one block to be reused in another block. So, I almost always use
\startMPcode begingroup; .... endgroup; \stopMPcode
to avoid such issues.
Aditya___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
participants (4)
-
Aditya Mahajan
-
Fabrice Couvreur
-
Hans Hagen
-
Taco Hoekwater