ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metapost
@ 2002-11-09 13:57 Michał Morawski
  2002-11-10 21:02 ` Metapost Hans Hagen
  2002-11-10 21:10 ` Metapost K.H. Wesseling
  0 siblings, 2 replies; 4+ messages in thread
From: Michał Morawski @ 2002-11-09 13:57 UTC (permalink / raw)


I have tried to repeat the example in the file "Creating metapost examples"
(mmakempy.pdf) and I receive result as below and empty place in my document.
Can anyone give me a hint?

This is MetaPost, Version 0.641 (Web2c 7.3.7x) (mem=metafun 2002.10.31)  31
OCT 2002 22:25
**&metafun mpgraph
(mpgraph.mp
{randomseed:=3603}
 (d:/TeXLive/texmf/metapost/base/graph.mp
(d:/TeXLive/texmf/metapost/base/format.mp
(d:/TeXLive/texmf/metapost/base/string.mp)
(d:/TeXLive/texmf/metapost/base/texnum.mp
>> d:/TeXLive/texmf/metapost/base/texnum.mp
>> texnum.mpx
! Unable to make mpx file.
l.14 init_numbers(btex
                      $-$etex, btex$1$etex, btex${\times}10$etex,
The two files given above are one of your source files
and an auxiliary file I need to read to find out what your
btex..etex blocks mean. If you don't know why I had trouble,
try running it manually through MPto -tex, TeX, and DVItoMP.


Thanks in advance
Michal

############################################
## Michał Morawski
## 95-200 Pabianice, Sempołowskiej 5 m 13
## tel/fax ++48 42 2262228
############################################
Zwykle niewinność jest wynikiem szczęścia a nie cnoty.
        Anatol France

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Metapost
  2002-11-09 13:57 Metapost Michał Morawski
@ 2002-11-10 21:02 ` Hans Hagen
  2002-11-10 23:43   ` Metapost Adam Lindsay
  2002-11-10 21:10 ` Metapost K.H. Wesseling
  1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen @ 2002-11-10 21:02 UTC (permalink / raw)
  Cc: ntg-context

At 02:57 PM 11/9/2002 +0100, you wrote:
>I have tried to repeat the example in the file "Creating metapost examples"
>(mmakempy.pdf) and I receive result as below and empty place in my document.
>Can anyone give me a hint?
>
>This is MetaPost, Version 0.641 (Web2c 7.3.7x) (mem=metafun 2002.10.31)  31
>OCT 2002 22:25
>**&metafun mpgraph
>(mpgraph.mp
>{randomseed:=3603}
>  (d:/TeXLive/texmf/metapost/base/graph.mp
>(d:/TeXLive/texmf/metapost/base/format.mp
>(d:/TeXLive/texmf/metapost/base/string.mp)
>(d:/TeXLive/texmf/metapost/base/texnum.mp
> >> d:/TeXLive/texmf/metapost/base/texnum.mp
> >> texnum.mpx
>! Unable to make mpx file.
>l.14 init_numbers(btex
>                       $-$etex, btex$1$etex, btex${\times}10$etex,
>The two files given above are one of your source files
>and an auxiliary file I need to read to find out what your
>btex..etex blocks mean. If you don't know why I had trouble,
>try running it manually through MPto -tex, TeX, and DVItoMP.

you have a name clash with a system file (somewhere else in your tex path); 
this can be solved by making sure that in case of context, tex searches on 
the local path first (can be done in texmf.cnf); i'm a bit puzzled, because 
context should make a fake file on the current path). Another option is to 
protect your temp job files with (in cont-sys.tex):

   \protectbufferstrue

or more obscure, you can change the name of the temp files,

   \def\MPgraphicfile{\bufferprefix mp\ifMPrun run\else graph\fi}

say mp -> mps , but first try the buffers

Hans

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Metapost
  2002-11-09 13:57 Metapost Michał Morawski
  2002-11-10 21:02 ` Metapost Hans Hagen
@ 2002-11-10 21:10 ` K.H. Wesseling
  1 sibling, 0 replies; 4+ messages in thread
From: K.H. Wesseling @ 2002-11-10 21:10 UTC (permalink / raw)


[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 1819 bytes --]

Many had trouble with btex etex including myself. A possible answer 
you might find in the appended context source file. You need a rather 
recent version context and a small handcrafted file by Hans as given 
in the text. It is rather wordy and not written for experts, but 
search for \forceMPTEXgraphictrue and you are in the neigbourhood. 
HGr...Karel.

On 9 Nov 2002, at 14:57, Micha  Morawski wrote:

> I have tried to repeat the example in the file "Creating metapost examples"
> (mmakempy.pdf) and I receive result as below and empty place in my document.
> Can anyone give me a hint?
> 
> This is MetaPost, Version 0.641 (Web2c 7.3.7x) (mem=metafun 2002.10.31)  31
> OCT 2002 22:25
> **&metafun mpgraph
> (mpgraph.mp
> {randomseed:=3603}
>  (d:/TeXLive/texmf/metapost/base/graph.mp
> (d:/TeXLive/texmf/metapost/base/format.mp
> (d:/TeXLive/texmf/metapost/base/string.mp)
> (d:/TeXLive/texmf/metapost/base/texnum.mp
> >> d:/TeXLive/texmf/metapost/base/texnum.mp
> >> texnum.mpx
> ! Unable to make mpx file.
> l.14 init_numbers(btex
>                       $-$etex, btex$1$etex, btex${\times}10$etex,
> The two files given above are one of your source files
> and an auxiliary file I need to read to find out what your
> btex..etex blocks mean. If you don't know why I had trouble,
> try running it manually through MPto -tex, TeX, and DVItoMP.
> 
> 
> Thanks in advance
> Michal
> 
> ############################################
> ## Micha  Morawski
> ## 95-200 Pabianice, Sempo owskiej 5 m 13
> ## tel/fax ++48 42 2262228
> ############################################
> Zwykle niewinno   jest wynikiem szcz  cia a nie cnoty.
>         Anatol France
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ref.ntg.nl
> http://ref.ntg.nl/mailman/listinfo/ntg-context
> 




[-- Attachment #2: Text from file 'BULLET.TEX' --]
[-- Type: text/plain, Size: 8727 bytes --]

% output=pdftex

%\def\Lit[#1]{\unskip\high{\in[lit:#1]}}
\def\Lit[#1]{[\in[lit:#1]]}

\setuphead[chapter][page=no,style=\bfc,after=\blank]
\setuphead[section][page=no,style=\bfb,after=\blank]
\setupwhitespace[big]

\usemodule[graph]

\starttext


\title[title]{Shifted bullets in graphs with \METAPOST}

\startnarrower
\startlines
Frans Goddijn
\type{frans@goddijn.com}
Karel H Wesseling
\type{k.h.wesseling@planet.nl}
\stoplines
\stopnarrower

\subject[abstract]{Abstract}

With \METAPOST\ fully integrated in \CONTEXT\ using this graphic 
language has become convenient. When we tried to use John Hobby's 
``Graph.mp'' package, however, it turned out to require extra
initializations and to produce unacceptable, shifted data graphs. 
Solutions to both problems are given. 


\section[introduction]{Introduction}

\METAPOST\ has become fun for these users when it became 
integrated in \CONTEXT, which was the trigger for this exercise, 
but the same can be done in \LATEX\ \Lit[popineau]. 
\METAPOST\ is known for the high precision of its graphics 
output and for its perfect scalability. Since this sounds 
promising also for the presentation of scientific data in 
graphical form we looked for a package that would ease the 
plotting of data files. This was found in the ``graph'' 
package written by John Hobby \Lit[hobby], the author of 
\METAPOST. In using this package we met with two problems: one, 
the lacking of proper initializations and two, the inaccurate 
placement of bullets at given coordinates. 


\section[initialization]{Initialization}

The inclusion of a \METAPOST\ graphics specification in a 
\CONTEXT\ document is simple and below is a code fragment that 
produces an XY||plot and places it as a graphic in this document. 

\starttyping
\startuseMPgraphic{plot}
  draw begingraph(3in,2in);
    gdraw "bdoffset.d";
    endgraph;
\stopuseMPgraphic
\midaligned{\useMPgraphic{plot}}
\stoptyping

\startuseMPgraphic{plot}
  draw begingraph(3in,2in);
    gdraw "bdoffset.d";
    endgraph;
\stopuseMPgraphic
\midaligned{\useMPgraphic{plot}}

With \type{\startuseMPgraphic{plot}} \CONTEXT\ is told that all 
instructions until the \type{\stopuseMPgraphic} are to be 
understood as \METAPOST||speak. \type{draw} is a \METAPOST\ 
instruction and \type{gdraw} is one included in Hobby's ``graph'' 
package which lives on top of \METAPOST. The file 
\type{bdoffset.d} is a small data file arranged as: 

\starttyping 
83 141 
93 118 
103 100 
113 86 
123 74 <EOF> 
\stoptyping 

This file must not have any extra empty lines (or all hell breaks 
loose). As a reminder, therefore, we placed an unnecessary 
\type{<EOF>} right after the final datum. The ``graph'' package 
accepts extra characters on a line, but no extra lines.

If you would try this program, the reason that it doesn't work 
right away is that the ``graph'' package has not been input. This 
would usually be accomplished by an instruction 

\starttyping 
\startMPinclusions input graph; \stopMPinclusions 
\stoptyping 

placed near the top between the start/stop of \type{useMPgraphic}.
Since extra initializations appeared also needed, however, Hans 
Hagen \footnote{of Pragma||ADE, the author of \CONTEXT.} wrote 
the following little module that must be input for use 
(\type{\usemodule[graph]}) in the preamble area of the source file, 
i.e. before \type{\starttext}: 

\starttyping
\forceMPTEXgraphictrue
\appendtoks
  initialize_numbers; % assure that pseudo typesetting is set up
  input graph;        % load the graph package
  Autoform:="@g";     % change the % template char into @
\to \MPinitializations
\stoptyping

Place these instructions in a file named \type{m-graph.tex} and 
the graph package is input, properly initialized, and ready for 
work. Note that the file \type{m-graph.tex} is input with 
\type{\usemodule[graph]}. When \CONTEXT\ reads 
\type{\usemodule} it inserts \type{m-} and appends \type{.tex} to 
the name automatically to find the correct file. Be sure to also 
place Hobby's \type{graph.mp} in the same directory or at least 
where it can be found by \CONTEXT. Using a rather recent version 
of \CONTEXT\ (see \about[references]) and this module, 
compile again, and the data plot shown above should result. 


\section[bullets]{Shifted bullets}

In the data plot the data pairs are plotted interconnected with 
straight lines. Since the curve is featureless the positions of 
the individual data points are barely discernable. Let us try to 
mark them more clearly. The manual for the ``graph'' package 
offers a solution. Simply replot the data but this time as 
bullets with the instruction 

\starttyping 
    gdraw "bdoffset.d" plot btex$\bullet$etex
\stoptyping

The \type{btex...etex} pair signifies to \METAPOST\ that the 
instructions in between should be interpreted as \TeX||typeset 
instructions. Thus, within the \CONTEXT\ document we first 
instruct \CONTEXT\ to look at a set of text lines as \METAPOST\ and 
within these lines \METAPOST\ is asked to consider some words as 
instructions to \TeX, which is why you need a recent version 
\CONTEXT. Still, the system works and the result is the following 
graphic: 

\startuseMPgraphic{plotbul}
  draw begingraph(3in,2in);
    gdraw "bdoffset.d";
    gdraw "bdoffset.d" plot btex$\bullet$etex;
    endgraph;
\stopuseMPgraphic
\midaligned{\useMPgraphic{plotbul}}

The dots don't fall on the line. Our first thought was that we 
did something wrong and our first action was to ask for help. Our 
second action was to check the graphic made with similar 
instructions in the ``graph'' manual. By tearing out the 
manual's page on which Fig.~2 is plotted and placing it over 
Fig.~1 such that the tick marks match we observed that equally in 
the manual the dots appear shifted towards the upper right. It 
turns out that \TeX\ positions each glyph with its reference 
point, not its midpoint, at the specified coordinates 
\Lit[knuth]. The reference point of the bullet is at the lower 
left of its box: \footnote{This can be observed in \CONTEXT\ by 
typing \type{\ruledhbox{$\bullet$}}} \ruledhbox{$\bullet$}. Thus, 
neither \TeX\ nor we did wrong but the instruction is wrong. 

The first solution suggested is to shift the bullet in opposite 
direction by replacing the \TeX\ instruction \type{$\bullet$} 
with:

\starttyping
  \kern-1mm\raisebox{-1mm}[0mm][0mm]{$\bullet$}
\stoptyping

which should shift the dot 1~mm to the left and 1~mm down, but 
doesn't. \TeX\ within \METAPOST\ within \CONTEXT\ forgets the 
original coordinates somewhere on the way and nothing is output. 
Since we hard||program shifts in mm for glyphs that could vary in 
dimension with the symbol specified it is not a general purpose 
solution either. Yet, it might have worked.

A solution which stays within \METAPOST\ came from the 
author of \METAFUN\ \Lit[hagen]. It declares and defines the 
bullet as a \METAPOST\ picture and plots the picture repeatedly 
at each coordinate specified. The full text of the example 
becomes: 

\starttyping 
\startuseMPgraphic{buldot} 
  picture Buldot; 
    Buldot:=image(draw origin withpen pencircle scaled 2mm;);
  draw begingraph(3in,2in);
    gdraw "other.d";
    gdraw "other.d" plot Buldot;
    endgraph;
\stopuseMPgraphic
\midaligned{\useMPgraphic{buldot}}
\stoptyping

\startuseMPgraphic{buldot}
  picture Buldot; 
    Buldot:=image(draw origin withpen pencircle scaled 2mm;);
  draw begingraph(3in,2in);
    gdraw "other.d";
    gdraw "other.d" plot Buldot;
    endgraph;
\stopuseMPgraphic
\midaligned{\useMPgraphic{buldot}}

The problem is solved. The `picture', of course, could be 
anything, like stars or squares or triangles or even doughnuts, 
as long as its midpoint is defined at the origin. And yes, we did 
change the data points to something more recognizable (a big 
dipper). 


\subject[acknowledgement]{Acknowledgement} 

We would like to express our appreciation to the respondents to 
our questions, they know who they are, that offered help and 
helped to a nice solution, all within the timespan of one 
workday. 


\subject[references]{References}

\startitemize[n,packed]
  \item[lit:popineau] Popineau F: \METAPOST\ pratique. Cahiers 
GUTenberg n\high{o}~41 |---| Novembre 2001.
  \item[lit:hobby] Hobby J D: Drawings graphs with MetaPost. 
\crlf \type{\texmf\doc\metapost\base\mpgraph.pdf}
  \item[lit:knuth] Knuth D E: The \TeX book (Chapter~11). Addison 
Wesley 1970. 
  \item[lit:hagen] Hagen H: Metafun. \crlf 
\type{\texmf\doc\context\manuals\metafun-p.pdf}
\stopitemize

The directory paths above are for the \TeX Live CDROM set, issue 
nr~7, June~2002, Volume~1. The \METAFUN\ manual and the \CONTEXT\ 
software are also available from \type{http://www.pragma-ade.com/} 

\stoptext


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Re: Metapost
  2002-11-10 21:02 ` Metapost Hans Hagen
@ 2002-11-10 23:43   ` Adam Lindsay
  0 siblings, 0 replies; 4+ messages in thread
From: Adam Lindsay @ 2002-11-10 23:43 UTC (permalink / raw)
  Cc: ntg-context

I believe Hans Hagen said this around Sun, 10 Nov 2002:

>>! Unable to make mpx file.
>>l.14 init_numbers(btex
>>                       $-$etex, btex$1$etex, btex${\times}10$etex,
>>The two files given above are one of your source files
>>and an auxiliary file I need to read to find out what your
>>btex..etex blocks mean. If you don't know why I had trouble,
>>try running it manually through MPto -tex, TeX, and DVItoMP.
>
>you have a name clash with a system file (somewhere else in your tex path); 
>this can be solved by making sure that in case of context, tex searches on 
>the local path first (can be done in texmf.cnf); i'm a bit puzzled, because 
>context should make a fake file on the current path). Another option is to 
>protect your temp job files with (in cont-sys.tex):

I just wanted to jump in here as someone who has also had exactly this
error when using mp-graph. It still has not entirely gone away (I try to
run "mpost mpgraph", and I still get the above error... that points to
the problem not being in ConTeXt alone), but Hans suggested a patch for
me last week...

HH, 30 October 2002:

>
>Maybe something has changed to graph.mp (esp the trigger for reloading it),
>
>in mp-form add a line at the top:
>
>   boolean mant_font ; mant_font := true ;
>
>this will prevent loading form.mp (which is replaced by a sligthly extended 
>version mp-form) and therefore loading of texnum

This indeed helped all graphs when running them through context, but the
underlying metapost problem remains when trying to run raw MP files with
'mpost'. FYI, I found the form.mp file Hans writes about in texmf/
metapost/context/mp-form.mp, at least in my TeXLive 7 install. (Hmm...
could this be a problem to TeXLive people?)

Good luck,
adam


--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Adam Lindsay                  +44(0)1524 594 537
 atl@comp.lancs.ac.uk
 http://www.comp.lancs.ac.uk/computing/users/atl/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-10 23:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-09 13:57 Metapost Michał Morawski
2002-11-10 21:02 ` Metapost Hans Hagen
2002-11-10 23:43   ` Metapost Adam Lindsay
2002-11-10 21:10 ` Metapost K.H. Wesseling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).