[NTG-context] Bibliography problems

2006-01-05 Thread David Antos

Hello,

I have several problems with the bibliography module in last stable
(2005.12.19).

You can find a minimal (well, as minimal as I was able to prepare ;)
example at http://www.fi.muni.cz/~xantos/biblio-example.tgz .

First, starting with the second page of bibliography, the beginnings of
lines are not aligned to the left.

Moreover, some entries produce an empty line after them. It seems probable
that some unwanted spaces appear in the macros.

In misc entries, only authors and titles are typeset. See the very first
entry cited in the document (Ha\v{z}muk): it contains howpublished and
month and they are ignored. BTW, is the \cite inside the bibliography entry
likely to work?

Can I correct my setups somehow to override those problems?

Thanks a lot,
D.A.

-- 
I have never let my schooling interfere with my education.
-- Mark Twain
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] How to do this in ConTeXt

2006-01-05 Thread R S Ananda Murthy

FabriceL. wrote:


Hi,

   Hans, it's so instructive to read yout post... I have learned from 
this last post 2 new commands !
However, I think the original poster wish a line who run to the right 
margin, so I added to your code
in the defineenumeration a inbetween=\vskip-4pt{\hrule height 
1.5pt}\blank. This is not very elegant,
but this works. By the way, I'm interested to know if there is a 
better solution.


 Hans wrote:
 one of you has to wikify this answer ...

I'm not sure how to do this, but I can try how this works.
The complete code follows.
FL.

\setupcolors[state=start]
\setupbackgrounds[text][text][background=color,backgroundcolor=darkred,backgroundoffset=3pt] 



\defineenumeration
 [example]
 [way=bychapter,
  separator=\compoundhyphen,
  chapternumber=yes,
  color=white,
  command=\exampleframed,
  inbetween=\vskip-4pt{\hrule height 1.5pt}\blank]

\defineframed
 [exampleframed]
 [background=color,
  backgroundcolor=black,
  foregroundcolor=white,
  style=bold,
  frame=off]

\starttext

\chapter{One}

\input tufte

\startexample
   \input tufte
\stopexample

\input tufte

\stoptext

___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context



Thank you FabriceL for your help. It worked.

Anand
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Bibliography problems

2006-01-05 Thread Taco Hoekwater


Hi David,

If \setupcite[compress=no] is acceptable to you, then I suggest
getting the latest beta of the bib module:

  http://tex.aanhet.net/bib/m-bib-beta-20051123b.zip

That should take care of your first points.

The misc entries need an adjusted (better) definition of
\setuppublicationlayout.  Try this (in your preamble):

  \setuppublicationlayout[misc]{%
\insertauthors{}{ }{\insertthekey{}{. }{}}%
\insertpubyear{(\insertmonth{}{, }{}}{). }{}%
\inserttitle{\bgroup }{\egroup \insertseries{ (}{)}. }{}%
\insertpublisher{}{. }{\inserthowpublished{}{. }{}}%
\insertpages{}{p. }{}%
\insertnote{ }{.}{}%
  }

Last I checked, \cite within the biblist typesets correctly,
but it does not actually make the record appear in the list
unless it is also cited elsewhere.

(the reason behind that is that it is apparently not possible
 to add stuff to a \definelist-ed list while that same list is
 being typeset).

Cheers, Taco

David Antos wrote:

Hello,

I have several problems with the bibliography module in last stable
(2005.12.19).

You can find a minimal (well, as minimal as I was able to prepare ;)
example at http://www.fi.muni.cz/~xantos/biblio-example.tgz .

First, starting with the second page of bibliography, the beginnings of
lines are not aligned to the left.

Moreover, some entries produce an empty line after them. It seems probable
that some unwanted spaces appear in the macros.

In misc entries, only authors and titles are typeset. See the very first
entry cited in the document (Ha\v{z}muk): it contains howpublished and
month and they are ignored. BTW, is the \cite inside the bibliography entry
likely to work?

Can I correct my setups somehow to override those problems?

Thanks a lot,
D.A.


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] present for mojca

2006-01-05 Thread Mojca Miklavec
Wow! Thank you a lot for this one, Hans!
(And to Peter as well!)

Hans Hagen wrote:
 Tobias Burnus wrote:

  Hi,
 
  Hans Hagen wrote:
 
  see attached file for usage
  %D   [   file=m-gnuplot,
 
 
 
  This does not work here, the produced .gpd file looks like:
  ---
  ^Mset title trigonometry^Mset terminal postscript
  set output gpl-gnuplot-1.ps
  ^Mplot sin(x)
  end
  ---
  ^M stands for \r (Carridge, decimal 13, hex 0d, oct 015).
 
  I frankly don't understand why one does not get a \n (linefeed,
  decimal 10/0A/012) or a ;\n for that matter
  [\def\par{;\rawcharacter{10}}].

I experience exactly the same problem here both under Windows and
Linux. ^M should be replaced by some newline. If I do that manually,
the module works perfectly.

A bit weird request (and not urgent at all since there are other ways
to solve this): could rotate= be added to \externalfigure once in
the distant future? The resulting graphs in postscript are rotated 90
degrees counterclocwise.

 do you use the natural.ctx file when building the format?

I think so (but not sure).

 maybe \def\par{; } also works here, i dunny how long gnuplot lines may be

The problem is not in \def\par{} I guess. It doesn't have any
influence on the way how input lines appear in the file. Even if I
redefined the \par and put strange chars in there, it didn't have any
influence.

I tried to play with \obeylines a bit, but without success. I managed
to get ^E (0x05) instead of ^M in the gnuplot file if I redefined
\endchar to be ^^L (if I remember correctly), but just anything else
led to errors.

Two not-so-important remarks:
1. \immediate\write\scratchwrite{end}
end should be changed into quit or even better: left out
completely since gnuplot exits anyway after executing the script

2. The default file extension is .plt (instead of gpd; the ending
really doesn't matter, but this one is recognized by default when you
open file from gnuplot)



Some terminals are more ugly than the others. The best idea to specify
the terminal is really by placing it manually into
\startGNUPLOTinclusion, not by prepending it automatically (as I asked
first), since it can have some additional parameters (color,
landscape, ...).

There are also set terminal pdf (only in the latest versions,
perhaps not even included in the binaries), set terminal png, set
terminal mp, set terminal latex, ...

Another humble request from me would be to support more than a single terminal:

%
\setupGNUPLOT[terminal=postscript] % should result in
\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.ps}%
...
\convertGNUPLOTgraphic{\bufferprefix gnuplot-\GNUPLOTnumber}%
% perhaps a better name, suggesting ps2pdf conversion


%
\setupGNUPLOT[terminal=pdf] % only recent; should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.pdf}%
% no postprocessing/conversion needed.

%
\setupGNUPLOT[terminal=png] % should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.png}%
% no postprocessing/conversion needed.

%
\setupGNUPLOT[terminal=mp] % should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.mp}%
% plus mpost + mptopdf postprocessing

%
\setupGNUPLOT[terminal=latex] % somewhat more tricky; should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.tex}%
% another auxilary file has to be used in this case with \documentclass ...
% \begindocument ... \input \bufferprefix gnuplot-\GNUPLOTnumber.tex
% and then processed with pdflatex; that's what I currently use: most
beautiful results


Thanks a lot,
Mojca

PS: Does this module really mean that I have no more excuses for not
finishing my report(s) for physics in time? ;)
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Bibliography problems

2006-01-05 Thread David Antos
On Thu, Jan 05, 2006 at 02:56:01PM +0100, Taco Hoekwater wrote:
   http://tex.aanhet.net/bib/m-bib-beta-20051123b.zip
 
 That should take care of your first points.

Hello,

yes, it works great!

 Last I checked, \cite within the biblist typesets correctly,
 but it does not actually make the record appear in the list
 unless it is also cited elsewhere.

Great, it's pretty reasonable.

Two minor issues:
I've included URL's into notes in bib file in the following format
  note = {\useURL[http://www.obfuscation.org/ipf/]
 [http://www.obfuscation.org/ipf/]
  \url[http://www.obfuscation.org/ipf/]}

It used to work well, with the latest version, the finishing ']' gets
typeset. I've tried to surround the fiinal \url macro with {} but it does
not work.

And finally, I refer to bibliography in many chapters, so I need
\setuplist[pubs][criterium=previous]
in order to make the complete list. I refer to publications in the appendix
that is placed *after* the bibliography. The entry from the appendix is
not typeset by \placepublications.

What is the correct \setuplist in this case?

Thanks a lot,
D.A.

-- 
The crew should smile, wave to farmers, people on tractors, law enforcement,
anyone else who is watching the balloon, and be polite at all times.
-- FAA Balloon Flying Handbook (FAA-H-8083-11)
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Bibliography problems

2006-01-05 Thread Mojca Miklavec
On 1/5/06, David Antos wrote:

 I've included URL's into notes in bib file in the following format
   note = {\useURL[http://www.obfuscation.org/ipf/]
  [http://www.obfuscation.org/ipf/]
   \url[http://www.obfuscation.org/ipf/]}

 It used to work well, with the latest version, the finishing ']' gets
 typeset. I've tried to surround the fiinal \url macro with {} but it does
 not work.

\url was redefined (sorry, that may be my fault) for the use within bibtex.

I don't know how to remove this little bug, but I would insert URLs
in the following way:

Inside .bib, use url= instead of note=

@Misc{compact-filter,
  key =  {Compact Filter},
  title ={{Compact Filter:  An IDD Based Packet Filter for Linux}},
  url = {http://www.cs.aau.dk/tilde-mixxel/cf/},
  month ={August},
  year = 2005
}

See bibl-apa.tex. It doesn't include URLs by default (perhaps it
should, but I don't know if it is still possible to do that without
people complaining because of the slightly changed behaviour if they
had url in their .bib files which were ignored before; comments?).

The example above is an @Misc, so you have to adapt the style for misc
to include url as well:

\setuppublicationlayout[misc]{%
   \insertauthors{}{ }{\insertthekey{}{. }{}}%
   \insertpubyear{(}{). }{}%
   \inserttitle{\bgroup }{\egroup \insertseries{ (}{)}. }{}%
   \insertpublisher{}{. }{}%
   \insertpages{}{p. }{}%
   \inserturl{}{}{}% ADDED
   \insertnote{ }{.}{}%
}

That way you'll get the desired output with much cleaner .bib files.
You can also use
\cite[url][compact-filter]
to get an active url in the document. (Taco, what are the square
brackets doing around the url in the resulting pdf?)

(I don't know if you can make the entry on the last page active as
well. In the example you didn't have it.)

The bad news is that you would have to do that for every possible type
of publication where you use URLs, but you used it in Misc only
anyway, so no additional work is needed.

Mojca
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] present for mojca

2006-01-05 Thread Hans Hagen

Mojca Miklavec wrote:


I experience exactly the same problem here both under Windows and
Linux. ^M should be replaced by some newline. If I do that manually,
the module works perfectly.
 


i hate locales


A bit weird request (and not urgent at all since there are other ways
to solve this): could rotate= be added to \externalfigure once in
the distant future? The resulting graphs in postscript are rotated 90
degrees counterclocwise.

 


hm, i have to think about it


maybe \def\par{; } also works here, i dunny how long gnuplot lines may be
   



 


did \def\par{;} work out ok?


The problem is not in \def\par{} I guess. It doesn't have any
influence on the way how input lines appear in the file. Even if I
redefined the \par and put strange chars in there, it didn't have any
influence.
 


strange, maybe i have a better tex binary


I tried to play with \obeylines a bit, but without success. I managed
to get ^E (0x05) instead of ^M in the gnuplot file if I redefined
\endchar to be ^^L (if I remember correctly), but just anything else
led to errors.

Two not-so-important remarks:
1. \immediate\write\scratchwrite{end}
end should be changed into quit or even better: left out
completely since gnuplot exits anyway after executing the script
 


ok, quit then


2. The default file extension is .plt (instead of gpd; the ending
really doesn't matter, but this one is recognized by default when you
open file from gnuplot)

 


hm, we don't want to overwrite files, do we?



Some terminals are more ugly than the others. The best idea to specify
the terminal is really by placing it manually into
\startGNUPLOTinclusion, not by prepending it automatically (as I asked
first), since it can have some additional parameters (color,
landscape, ...).
 

it's not prepended now; however, it makes sense to think about it 
because in the case of mp we need a different treatment



There are also set terminal pdf (only in the latest versions,
perhaps not even included in the binaries), set terminal png, set
terminal mp, set terminal latex, ...

Another humble request from me would be to support more than a single terminal:

%
\setupGNUPLOT[terminal=postscript] % should result in
\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.ps}%
...
\convertGNUPLOTgraphic{\bufferprefix gnuplot-\GNUPLOTnumber}%
% perhaps a better name, suggesting ps2pdf conversion


%
\setupGNUPLOT[terminal=pdf] % only recent; should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.pdf}%
% no postprocessing/conversion needed.

%
\setupGNUPLOT[terminal=png] % should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.png}%
% no postprocessing/conversion needed.

%
\setupGNUPLOT[terminal=mp] % should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.mp}%
% plus mpost + mptopdf postprocessing

%
\setupGNUPLOT[terminal=latex] % somewhat more tricky; should result in

\immediate\write\scratchwrite{set output \bufferprefix
gnuplot-\GNUPLOTnumber.tex}%
% another auxilary file has to be used in this case with \documentclass ...
% \begindocument ... \input \bufferprefix gnuplot-\GNUPLOTnumber.tex
% and then processed with pdflatex; that's what I currently use: most
beautiful results

 


that's a big list ... why isn't there a context mode?


Thanks a lot,
   Mojca

PS: Does this module really mean that I have no more excuses for not
finishing my report(s) for physics in time? ;)
 

 


no, worse, you now can finish it faster

see attached file (bottom of file); should be enough to get your reports 
done


Hans
%D \module
%D   [   file=m-gnuplot,
%Dversion=2006.01.04,
%D  title=\CONTEXT\ Extra Modules,
%D   subtitle=\GNUPLOT\ Inclusion,
%D author=Hans Hagen,
%D   date=\currentdate,
%D  copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% todo: reuse (only if really needed)

% \enablemode[demo]

%D example:
%D
%D \starttyping
%D texexec --pdf --mode=demo m-gnuplot
%D \stoptyping

\unprotect

\ifx\operatingsystem\undefined \def\operatingsystem{unix} \fi % texexec will set that

\newcounter\GNUPLOTnumber

\def\startGNUPLOTinclusions
  {\bgroup
   \obeylines
   \dostartGNUPLOTinclusions}

\def\dostartGNUPLOTinclusions#1\stopGNUPLOTinclusions
  {\gdef\GNUPLOTinclusions{#1}%
   \egroup}

\def\startGNUPLOTgraphic#1%
  {\bgroup
   \obeylines
   \dostartGNUPLOTgraphic{#1}}

\def\dostartGNUPLOTgraphic#1#2\stopGNUPLOTgraphic
  {\doglobal\increment\GNUPLOTnumber
   \letgvalue{gpg:n:#1}\GNUPLOTnumber
   \setgvalue{gpg:d:\GNUPLOTnumber}{#2}%
   \egroup}

\def\useGNUPLOTgraphic
  {\dodoubleempty\douseGNUPLOTgraphic}

\def\douseGNUPLOTgraphic[#1][#2]%
  {\iffirstargument
 [EMAIL PROTECTED] % like \externalfigure[name][optional args]
   \else
 [EMAIL PROTECTED] % like 

Re: [NTG-context] Bibliography problems

2006-01-05 Thread David Antos
On Thu, Jan 05, 2006 at 07:03:03PM +0100, Mojca Miklavec wrote:
 I don't know how to remove this little bug, but I would insert URLs
 in the following way:

Hello,

systematically, sure ;)

 to get an active url in the document. (Taco, what are the square
 brackets doing around the url in the resulting pdf?)

Is there an easy way to remove the right square bracket? I don't need
clickable URL's and I'm under extreme time pressure now. I'm sorry to say,
but I'd be happy for an ugly hack ;)

Thanks a lot,
D.A.

-- 
...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and
the Ugly).
-- Matt Welsh
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Bibliography problems

2006-01-05 Thread Taco Hoekwater

David Antos wrote:

On Thu, Jan 05, 2006 at 07:03:03PM +0100, Mojca Miklavec wrote:


I don't know how to remove this little bug, but I would insert URLs
in the following way:



Hello,

systematically, sure ;)



to get an active url in the document. (Taco, what are the square
brackets doing around the url in the resulting pdf?)



Is there an easy way to remove the right square bracket? I don't need
clickable URL's and I'm under extreme time pressure now. I'm sorry to say,
but I'd be happy for an ugly hack ;)


Removing 'url' from  the bibcommandlist (line 440 of t-bib.tex) should
work out OK in your case.

A 'nice' solution needs quite some thinking

Cheers,
 Taco
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Arithmetic Overflow

2006-01-05 Thread David Arnold
All,  Is there a switch I can set to get rid of the arithmetic  
overflow in the following example?


%output=pdf

\setupcolors[state=start]

\definecolor[gridlines][s=0.7]

\startMPinclusions

color gridlines; gridlines:=\MPcolor{gridlines};

vardef create_grid (expr l,r,h,b,t,v,wid,ht)=
  save ux, uy; numeric ux, uy;
  (r-l)*ux=wid; (t-b)*uy=ht;
  for k=b step v until t:
draw (l*ux,k*uy)--(r*ux,k*uy) withcolor \MPcolor{gridlines};
  endfor;
  for k=l step h until r:
draw (k*ux,b*uy)--(k*ux,t*uy) withcolor \MPcolor{gridlines};
  endfor;
enddef;

vardef create_axes (expr l,r,b,t,wid,ht,blbl) (text xlbl,ylbl) =
  save ux, uy; numeric ux, uy;
  (r-l)*ux=wid; (t-b)*uy=ht;
  textextoffset:=3pt;
  drawdblarrow (1.05*l*ux,0)--(1.05*r*ux,0);
  draw textext.rt(xlbl) shifted (1.05*r*ux,0);
  if blbl:draw textext.bot(decimal r) shifted (r*ux,0); fi;
  drawdblarrow (0,1.05*b*uy)--(0,1.05*t*uy);
  draw textext.top(ylbl) shifted (0,1.05*t*uy);
  if blbl: draw textext.lft(decimal t) shifted (0,t*uy); fi;
enddef;

vardef drawfcn (expr ind,dep,l,r,b,t,wid,ht,n) text txt =
  save x, dx, ux, uy; numeric x, dx, ux, uy;
  dx:=(r-l)/n;
  (r-l)*ux=wid; (t-b)*uy=ht;
  save cpath; path cpath; cpath:=(l,b)--(r,b)--(r,t)--(l,t)--cycle;
  save p; path p; hide (x:=l;) p:=(scantokens(ind),scantokens(dep));
  for xx:=l step dx until r:
hide (x:=xx;) p:=p--(scantokens(ind),scantokens(dep));
  endfor;
  hide(x:=r;) p:=p--(scantokens(ind),scantokens(dep));
  p:=p cutbefore cpath;
  p:=reverse p;
  p:=p cutbefore cpath;
  p:=p xyscaled (ux,uy);
  drawdblarrow p txt;
enddef;

\stopMPinclusions

\starttext


\startMPpage %figure library name: x2

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x*x,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\startMPpage %figure library name: x4

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x**4,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\startMPpage %figure library name: x6

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x**6,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\stoptext

%%% Local Variables:
%%% mode: conTeXt-en
%%% End:


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Arithmetic Overflow

2006-01-05 Thread David Arnold
I found warningcheck:=0. Anything allow me to get even bigger numbers  
to work?


On Jan 5, 2006, at 6:15 PM, David Arnold wrote:

All,  Is there a switch I can set to get rid of the arithmetic  
overflow in the following example?


%output=pdf

\setupcolors[state=start]

\definecolor[gridlines][s=0.7]

\startMPinclusions

color gridlines; gridlines:=\MPcolor{gridlines};

vardef create_grid (expr l,r,h,b,t,v,wid,ht)=
  save ux, uy; numeric ux, uy;
  (r-l)*ux=wid; (t-b)*uy=ht;
  for k=b step v until t:
draw (l*ux,k*uy)--(r*ux,k*uy) withcolor \MPcolor{gridlines};
  endfor;
  for k=l step h until r:
draw (k*ux,b*uy)--(k*ux,t*uy) withcolor \MPcolor{gridlines};
  endfor;
enddef;

vardef create_axes (expr l,r,b,t,wid,ht,blbl) (text xlbl,ylbl) =
  save ux, uy; numeric ux, uy;
  (r-l)*ux=wid; (t-b)*uy=ht;
  textextoffset:=3pt;
  drawdblarrow (1.05*l*ux,0)--(1.05*r*ux,0);
  draw textext.rt(xlbl) shifted (1.05*r*ux,0);
  if blbl:draw textext.bot(decimal r) shifted (r*ux,0); fi;
  drawdblarrow (0,1.05*b*uy)--(0,1.05*t*uy);
  draw textext.top(ylbl) shifted (0,1.05*t*uy);
  if blbl: draw textext.lft(decimal t) shifted (0,t*uy); fi;
enddef;

vardef drawfcn (expr ind,dep,l,r,b,t,wid,ht,n) text txt =
  save x, dx, ux, uy; numeric x, dx, ux, uy;
  dx:=(r-l)/n;
  (r-l)*ux=wid; (t-b)*uy=ht;
  save cpath; path cpath; cpath:=(l,b)--(r,b)--(r,t)--(l,t)--cycle;
  save p; path p; hide (x:=l;) p:=(scantokens(ind),scantokens(dep));
  for xx:=l step dx until r:
hide (x:=xx;) p:=p--(scantokens(ind),scantokens(dep));
  endfor;
  hide(x:=r;) p:=p--(scantokens(ind),scantokens(dep));
  p:=p cutbefore cpath;
  p:=reverse p;
  p:=p cutbefore cpath;
  p:=p xyscaled (ux,uy);
  drawdblarrow p txt;
enddef;

\stopMPinclusions

\starttext


\startMPpage %figure library name: x2

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x*x,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\startMPpage %figure library name: x4

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x**4,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\startMPpage %figure library name: x6

%initialize window parameters
numeric xmin, xmax, xscl, ymin, ymax, yscl;
xmin:=-10;
xmax:=10;
xscl:=1;
ymin:=-10;
ymax:=10;
yscl:=1;

%initialize number of points
numeric num_points;
num_points:=100;

%initialize dimensions of image
numeric width, height;
width=1.5in;
height=1.5in;

%create the grid
create_grid(xmin,xmax,xscl,ymin,ymax,yscl,width,height);

boolean lbl_scl; lbl_scl:=true;

%create the axes
create_axes(xmin,xmax,ymin,ymax,width,height,lbl_scl)($x$)($y$);

%draw the function
drawfcn(x,x**6,xmin,xmax,ymin,ymax,width,height,100)
withcolor blue ;

\stopMPpage

\stoptext

%%% Local Variables:
%%% mode: conTeXt-en
%%% End:


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context