Q: about \externalfile from metafun-p.pdf
Hi, i'm starting to learn context and therefore i have copied some examples from metafun-p.pdf and get the following error: --- ! Undefined control sequence. l.42 \externalfile [mprun.21][width=5cm] --- --- texexec --version TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005 texexec : TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005 texutil : TeXUtil 9.0.0 - ConTeXt / PRAGMA ADE 1992-2004 tex : pdfeTeX, 3.141592-1.30.3-2.2 (Web2C 7.5.5) context : ver: 2005.07.27 cont-en : ver: 2005.07.27 fmt: 2005.10.1 mes: english total run time : 2 seconds --- The context code: --- \language[de] \setupcolors[state=start] \setupoutput[pdftex] \setuppapersize[A4][A4] \setuppagenumbering[location={footer,right}] \setupfootertexts[][{Seite \pagenumber{} von \totalnumberofpages}] \starttext % in the metapost_test is the code from page 118 => beginfig(21) ;... \startMPrun input metapost_test; \stopMPrun \externalfile[mprun.21][width=5cm] \showsetups \showlayout \stoptext --- Please can any body help, thx. al ;-)
Alexander Lazic wrote:
i'm starting to learn context and therefore i have copied some examples from metafun-p.pdf and get the following error:
--- ! Undefined control sequence. l.42 \externalfile [mprun.21][width=5cm]
Probably a typo in metafun-p.pdf; try \externalfigure instead. Christopher
On Son 02.10.2005 19:54, Christopher Creutzig wrote:
Probably a typo in metafun-p.pdf; try \externalfigure instead.
Thanx this works ;-) Oh btw: i have see in the syntax-diagramm sin. 1.) is this the sinus function? 2.) i have try --- \startreusableMPgraphic{sin} sin (1); \stopreusableMPgraphic{sin} \reuseMPgraphic{sin} --- and get: Isolated expression. Do you know what's going wrong? al ;-)
Alexander Lazic wrote:
Oh btw: i have see in the syntax-diagramm sin.
1.) is this the sinus function?
Sure. (The sine function as used by mathematicians. If you want the sine of an angle expressed in degrees, I believe you want sind.)
2.) i have try
--- \startreusableMPgraphic{sin}
sin (1); \stopreusableMPgraphic{sin}
This {sin} at the end is wrong; it's interpreted as text.
\reuseMPgraphic{sin} ---
and get:
Isolated expression.
Do you know what's going wrong?
It's the same error as trying to “plot” the MP code 1; MetaPost is confused since it has no idea what to do with that number and tells you so. Since MP can handle more than just numbers, you get a slightly more general error message that talks about an “expression” rather than a “number.” What you can do is something like \starttext \startusableMPgraphic{sin} for x := 0 step 0.6282 until 6.282: drawdot(10*x, 10*sin(x)) withpen pencircle scaled 1pt; endfor \stopusableMPgraphic \useMPgraphic{sin} \stoptext Or, you can use the fact that in MetaPost you can build up an expression within a for loop as follows: \starttext \startusableMPgraphic{sin} draw (0,0) for x := 0 step 0.2 until 6.282: ..(10*x, 10*sin(x)) endfor; \stopusableMPgraphic \useMPgraphic{sin} \stoptext I think it really helps with MP programming to understand this type of loops. Christopher
On Son 02.10.2005 22:36, Christopher Creutzig wrote:
Alexander Lazic wrote:
2.) i have try
\startreusableMPgraphic{sin}
sin (1); \stopreusableMPgraphic{sin}
This {sin} at the end is wrong; it's interpreted as text.
This have i understand ;-) I called it sin, sorry for confusion.
What you can do is something like
drawdot(10*x, 10*sin(x)) withpen pencircle scaled 1pt;
Thanx. Have i right understand, if i want to draw a sinuscurve i must use a for-loop?
I think it really helps with MP programming to understand this type of loops.
Well i think i must learn mp before context, if i want to draw some mathemathics functions ;-) Thanx again for help. greetings al ;-)
Alexander Lazic wrote:
\stopreusableMPgraphic{sin}
This {sin} at the end is wrong; it's interpreted as text.
This have i understand ;-) I called it sin, sorry for confusion.
The name is unimportant – my point is that the \stop... commands don't get arguments.
Thanx. Have i right understand, if i want to draw a sinuscurve i must use a for-loop?
MetaPost is not really a function plotter. So, yes, you have to use some sort of loop, although there may be some predefined macros hiding them. Christopher
On Mon 03.10.2005 19:26, Christopher Creutzig wrote:
MetaPost is not really a function plotter. So, yes, you have to use some sort of loop, although there may be some predefined macros hiding them.
Is there a better way in ConTeXt/tex for this?! Should i use some external Programms for this? al ;-)
Alexander Lazic wrote:
On Mon 03.10.2005 19:26, Christopher Creutzig wrote:
MetaPost is not really a function plotter. So, yes, you have to use some sort of loop, although there may be some predefined macros hiding them.
Is there a better way in ConTeXt/tex for this?!
Should i use some external Programms for this?
Not really, that causes all sorts of problems when trying to get the same font all over the place etc. But you might be interested (assuming you can read or at least decipher French) in the pages at http://melusine.eu.org/syracuse/metapost/galeries/ – complete code included. (Those are the predefined macros I was talking about above.) I guess something like http://melusine.eu.org/syracuse/metapost/galeries/courbes02/07riemann-img.ht... should wet your appetite. :-) Regards, Christopher
On Die 04.10.2005 18:07, Christopher Creutzig wrote:
But you might be interested (assuming you can read or at least decipher French) in the pages at http://melusine.eu.org/syracuse/metapost/galeries/ ? complete code included. (Those are the predefined macros I was talking about above.)
Thanx for that link looks very nice ;-) greetings al ;-)
Alexander Lazic wrote:
On Mon 03.10.2005 19:26, Christopher Creutzig wrote:
MetaPost is not really a function plotter. So, yes, you have to use some sort of loop, although there may be some predefined macros hiding them.
Is there a better way in ConTeXt/tex for this?!
Should i use some external Programms for this?
al ;-)
I use gnuplot which makes graphs of superb visual quality and has extensive support for many different function manipulations and weird stuff that you want to do with it. I do something like: set terminal latex set output "file.tex" set title '\bf My wonderful function $sin(\omega t)$' set xlabel '$t\ \rm[s]$' set ylabel '$A$' plot sin(x) and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the resulting PDFs in your ConTeXt source. (Gnuplot is one of the very few examples where I still use LaTeX.) You can also output the (ConTeXt-friendly) metapost (with set terminal), but you lose on quality. Mojca
On Die 04.10.2005 19:48, Mojca Miklavec wrote:
I use gnuplot which makes graphs of superb visual quality and has extensive support for many different function manipulations and weird stuff that you want to do with it.
I have also think on gnuplot, but wasn't sure that i can use the ps/pdf into my context doc.
and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the resulting PDFs in your ConTeXt source. (Gnuplot is one of the very few examples where I still use LaTeX.) You can also output the (ConTeXt-friendly) metapost (with set terminal), but you lose on quality.
Well i will also try with gnuplot. How much bad is 'lose quality' in %? greetings al ;-)
Alexander, There is a lot of plots you can do with Metapost. Ordinary, every day stuff. For example: beginfig(1); % initialize a and c for f(x)=|x-a| and g(x)=c numeric a, c; a=-2; c=2; % initialize function label abcissas and postions numeric flabel, glabel; flabel:=-5; glabel:=-5; % define function f(x)=|x-a| vardef f(expr x)= abs(x-a) enddef; % draw line with given point and slope path F; F:=(-5,f(-5)); for x=-5 step 1 until 5: F:=F--(x,f(x)); endfor; % initialize scale numeric u; 10u=4cm; % the line F:=F scaled 1u; draw F withcolor blue; % clipping path path cpath; cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle; cpath:=cpath scaled 1u; % clip and save current picture picture pic; clip currentpicture to cpath; pic:=currentpicture; % erase currentpicture currentpicture:=nullpicture; % draw grid for k=-5u step 1u until 5u: draw (-5u,k)--(5u,k) withcolor 0.85white; draw (k,-5u)--(k,5u) withcolor 0.85white; endfor; % draw axes drawarrow (-5u,0)--(5u,0); drawarrow (0,-5u)--(0,5u); % label axes label.rt(btex $x$ etex, (5.2u,0)); label.top(btex $y$ etex, (0,5.2.u)); label.bot(btex $5$ etex, (5u,0)); label.lft(btex $5$ etex, (0,5u)); % redraw line draw pic; % label the functions f(x)=|x-a| and g(x)=c pair D, E; D:=(-5,f(-5)) scaled u; label.lft(btex $f$ etex,D); E:=(-5,2) scaled u; label.lft(btex $g$ etex, E); % draw the graph of g(x)=c path G; G:=(-5,2)--(5,2); G:=G scaled u; draw G withcolor blue; endfig; end. And for a good stats package, see: http://www-math.univ-poitiers.fr/~phan/statsmac.html And for good circuits diagrams, see: http://www.cnm.es/~pserra/schema/whatis.html Don't give up on Metapost too soon. It's an awesome language and the file size created are small, a plus when you're document includes lots of figures and you want it to download in reasonable time on the internet.
Hi, On Die 04.10.2005 23:17, David Arnold wrote:
[Very helpfull text snipped] Wow thanx ;-)
And for a good stats package, see:
http://www-math.univ-poitiers.fr/~phan/statsmac.html
And for good circuits diagrams, see:
Thanx also.
Don't give up on Metapost too soon. It's an awesome language and the file size created are small, a plus when you're document includes lots of figures and you want it to download in reasonable time on the internet.
Well i give me the time to learn this language ;-) al ;-)
Mojca Miklavec wrote:
and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the
Since afaik ConTeXt does not have an equivalent of LaTeX's picture environment, I don't see much point in teaching gnuplot some sort of ConTeXt output. I'm no gnuplot expert, but my guess is that tweaking the metapost prologues and some minor code tweaks would probably be the easiest way to go.
examples where I still use LaTeX.) You can also output the (ConTeXt-friendly) metapost (with set terminal), but you lose on quality.
In what respect do you lose quality? Christopher
Christopher Creutzig wrote:
Mojca Miklavec wrote:
and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the
Since afaik ConTeXt does not have an equivalent of LaTeX's picture environment, I don't see much point in teaching gnuplot some sort of ConTeXt output. I'm no gnuplot expert, but my guess is that tweaking the metapost prologues and some minor code tweaks would probably be the easiest way to go.
context has some equivalent, positions, which i nowadays never use even better is to use layers, so if someone is willing to write the code for gnuplot, i can provide the context snippets Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
It's been a while since I used gnuplot, but at one time it was able to export as Metapost code. Does it still do that? On Oct 5, 2005, at 12:18 AM, Hans Hagen wrote:
Christopher Creutzig wrote:
Mojca Miklavec wrote:
and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the
Since afaik ConTeXt does not have an equivalent of LaTeX's picture environment, I don't see much point in teaching gnuplot some sort of ConTeXt output. I'm no gnuplot expert, but my guess is that tweaking the metapost prologues and some minor code tweaks would probably be the easiest way to go.
context has some equivalent, positions, which i nowadays never use
even better is to use layers, so if someone is willing to write the code for gnuplot, i can provide the context snippets
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
David
Mojca Miklavec wrote:
I use gnuplot which makes graphs of superb visual quality and has extensive support for many different function manipulations and weird stuff that you want to do with it. I do something like:
set terminal latex set output "file.tex" set title '\bf My wonderful function $sin(\omega t)$' set xlabel '$t\ \rm[s]$' set ylabel '$A$' plot sin(x)
and then "\input file" inside of the main LaTeX file. Gnuplot cannot make output in ConTeXt (yet), but perhaps you can include the resulting PDFs in your ConTeXt source. (Gnuplot is one of the very few examples where I still use LaTeX.) You can also output the (ConTeXt-friendly) metapost (with set terminal), but you lose on quality.
gnuplot is great indeed, but the output is rather large; it would be nice if there was a real good output mode (say, comparable to the output produced by metapost: compact, parsable); btw, is it really that difficult to use gnuplot output in context? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Mit 05.10.2005 09:05, Hans Hagen wrote:
gnuplot is great indeed, but the output is rather large; it would be nice if there was a real good output mode (say, comparable to the output produced by metapost: compact, parsable);
Ack.
btw, is it really that difficult to use gnuplot output in context?
Not really because if you use png or i think some other output fileformats. But i think you lose some benefit of metapost, or have i the wrong point of view?! Greetings al ;-)
gnuplot is great indeed, but the output is rather large; it would be nice if there was a real good output mode (say, comparable to the output produced by metapost: compact, parsable);
btw, is it really that difficult to use gnuplot output in context?
Hans
I often use metapost output from gnuplot indeed, then pass it through a short sed script to do stuff like adding \start/stopuseMPgraphic commands and cleaning the preamble. I think gnuplot does a great job in general. For more complex graphs, I prefer the mp-graph package. Regards, David
Hans Hagen wrote:
gnuplot is great indeed, but the output is rather large; it would be nice if there was a real good output mode (say, comparable to the output produced by metapost: compact, parsable);
LaTeX mode IS parsable and I often edit it manually (except the part which does the smooth plotting of functions with lines; smooth lines are composed from hundreds of points and that part makes the files huge). Drawing only the points results in a reasonably small file.
btw, is it really that difficult to use gnuplot output in context?
No. A file context.trm (http://cvs.sourceforge.net/viewcvs.py/gnuplot/gnuplot/term/) should be written by modifiying the postscript/metapost/latex.trm and perhaps some layer should be added in ConTeXt for \startgnuplot ... \stopgnuplot. Metapost can already be used, perhaps only some interaction with ConTeXt is missing (setting point shapes & colors, fonts, ... somewhere at the beginning or in a separate style file). To answer Christophers's and Alexander's question about quality of metapost output: I guess I mixed it up with pslatex when I was talking about the output quality. You can't express it in percentage. See http://pub.mojca.org/tex/gnuplot/trlin.pdf for an example graph with latex/pslatex/mp as rendering terminal. The second example could be easily manually tuned a bit afterwards. Linewidths & typesetting in general is a bit worse (from my point of view), but there's no such quality loss as if you use PNGs. Mojca
Mojca Miklavec wrote:
about the output quality. You can't express it in percentage. See http://pub.mojca.org/tex/gnuplot/trlin.pdf for an example graph with latex/pslatex/mp as rendering terminal.
People often (incorrectly) claim you can't argue preferences, but I'd say the MP version wins hands down in this particular example. :-) Christopher
On Tue, 4 Oct 2005, Alexander Lazic wrote:
On Mon 03.10.2005 19:26, Christopher Creutzig wrote:
MetaPost is not really a function plotter. So, yes, you have to use some sort of loop, although there may be some predefined macros hiding them.
Is there a better way in ConTeXt/tex for this?!
You could also try PSTricks: \usemodule[pstric] \starttext \startPSTRICKS \psplot[plotpoints=100]{0}{1}{x 360 mul sin} \stopPSTRICKS \stoptext Cheers, Peter -- http://pmrb.free.fr/contact/
Hi, On Die 04.10.2005 21:14, Peter Münster wrote:
You could also try PSTricks:
\usemodule[pstric] \starttext \startPSTRICKS \psplot[plotpoints=100]{0}{1}{x 360 mul sin} \stopPSTRICKS \stoptext
Thanx i have try an get: figures : figure pstest-texapp can not be found but there is the file: pstest-texapp.tex You can get the output and some otherfiles from: http://www.none.at/tex/ Greetings al ;-)
On Tue, 4 Oct 2005, Alexander Lazic wrote:
\usemodule[pstric] \starttext \startPSTRICKS \psplot[plotpoints=100]{0}{1}{x 360 mul sin} \stopPSTRICKS \stoptext
Thanx i have try an get:
figures : figure pstest-texapp can not be found
but there is the file: pstest-texapp.tex
Hello Alexander, I don't understand your problem, but perhaps you should write the psplot command inside a \pspicture(0,-1)(1,1) ... \endpspicture. Cheers, Peter -- http://pmrb.free.fr/contact/
Peter Münster wrote:
On Tue, 4 Oct 2005, Alexander Lazic wrote:
\usemodule[pstric] \starttext \startPSTRICKS \psplot[plotpoints=100]{0}{1}{x 360 mul sin} \stopPSTRICKS \stoptext
Thanx i have try an get:
figures : figure pstest-texapp can not be found
but there is the file: pstest-texapp.tex
Hello Alexander, I don't understand your problem, but perhaps you should write the psplot command inside a \pspicture(0,-1)(1,1) ... \endpspicture. Cheers, Peter
This works for me (I suppose your code is in pstest-texapp.tex): $> texexec --output=dvips pstest-texapp.tex $> dvips -o pstest-texapp.ps pstest-texapp.dvi $> ps2pdf14 pstest-texapp.ps luigi
On Mit 05.10.2005 08:43, luigi.scarso wrote:
Peter Münster wrote:
I don't understand your problem, but perhaps you should write the psplot command inside a \pspicture(0,-1)(1,1) ... \endpspicture.
This works for me (I suppose your code is in pstest-texapp.tex):
Thanx both for your answer, i think i need some more time with context&&metapost ;-) @all: I will work thru all your answers and tips, thanx again all for our help and points ;-)) Greetings from austria. al ;-)
participants (8)
-
Alexander Lazic
-
Christopher Creutzig
-
David Arnold
-
David Munger
-
Hans Hagen
-
luigi.scarso
-
Mojca Miklavec
-
Peter Münster