7 Sep 13:48 2003

latexMP (was: using fonts with metapost)

On Fri, 7 Mar 2003 15:14:15 +0100
Jens-Uwe Morawski <morawski <at> gmx.net> wrote:

> On Fri, 07 Mar 2003 12:59:21 +0100
> Patrick Gundlach <pg <at> levana.de> wrote:
> > 3) the width of the labels (btex ... etex pictures) have a strange
> >    width. I had no closer look at this but it seems as if the widest
> >    text determines the width of all other texts. So I had to use
> >    setbounds p to sometightpath' in order to avoid lables at the right
> >    side of the picture make the bbox of the overall picture distorted.
>
> can you give a problematic example
>
> > But with the setbounds statement, no. 3 is wonderful!
>
> i've an idea how no. 3 could work with only one MP call.
> wait a minute... (or two, or three...)

this was the situation in march and now i can offer a MP-package
that implements fast and efficient LaTeX-typesetting in MetaPost.

Before i upload the package to CTAN i would like that other
MP users have a look and test this package.

Please test it and give me some feedback. TIA.

Jens


Attachment (latexmp.zip): application/zip, 6699 bytes

8 Sep 17:25 2003

Re: latexMP (new feature)


This is a new version of latexMP
( Martin, sorry that you get this attachment twice)

It implements a long missing feature called 'multicolor labels'.
For example, the following string

"a \textcolor{red}{short text} \textcolor{blue}{is" &
"\textcolor{green}{sometimes} not} long enough."

will typeset:
"a " and " long enough." in black
"short text" in red
"is " and " not" in blue
"sometimes" in green

This feature is implemented in MetaPost using a parser for the string.
Since parsing text is sometimes slow, this feature has to be activated
with option 'multicolor'; see doc and lmp-mc.mp.

Jens

Attachment (latexmp.zip): application/zip, 8 KiB
9 Sep 16:01 2003

Graph.mp annoyances

Hi all,

I am using the metapost graph macro a lot, but it has a few minor
annoyances. Maybe some of you have already solved the following problems:

* The direction of arrowheads in gdrawarrow does not follow the curve it
is on.

* Reading data from a file only works if there is exactly one empty line
between data for each curve and the error message is not helpful

* Data with exponent as 1e4 cannot have a capital E.

* Curves from data are always polygonal, unless one changes the true
argument to GMcvi_ in Gdraw_. If this is set to false a very special
kind of curve is created. Why does the branch for false have post- and
precontrol of the curve, not just .. which makes a nice, smooth curve?

* Axes can only be in the llft of the graph, not through the origin.

* Frames can only be avoided if the internal variable  Gneedfr_  is set
to false. An empty argument to frame would be nice.

I am very interested in any remedies to these issues.

regards,
--

--
Brian Elmegaard (be <at> mek.dtu.dk)
Dept. of Mechanical Engineering, Energy Engineering,
Technical University of Denmark, Phone +45 4525 4169  Fax +45 4593 5215


9 Sep 18:13 2003

Re: latexMP (new feature)

On Tue, 09 Sep 2003 15:47:29 +0200
Brian Elmegaard <be <at> mek.dtu.dk> wrote:

Ahoi Brian,

> I really appreciate this effort. It looks very fine, but on the other
> hand, the syntax of what was known as verbatimtex is far from the usual
> latex-like one. Does your way of solving the problem exclude the usual
> verbatimtex-syntax?

1) the verbatim-etex-syntax is completely hidden from the user
2) the verbatim-etex-setup normally only works for btex...etex.
This doesn't allow variables to be expanded, since
btex...etex is typeset prior the actual MP run.

LaTeXMP allows dynamic labels, i.e. labels that include runtime
variables and, as already said, it hides the verbatim-etex-stuff.

Example:

input latexmp ;

setupLaTeXMP(
mode=rerun,
packages="helvet[scaled=0.9]",
definitions="\renewcommand{\familydefault}{\sfdefault}",
multicolor=true, textextlabel=true) ;



9 Sep 21:33 2003

Re: [metafont] Graph.mp annoyances

On Tue, 9 Sep 2003, Brian Elmegaard wrote:

> Hi all,
>
> I am using the metapost graph macro a lot, but it has a few minor
> annoyances. Maybe some of you have already solved the following problems:
>
> * The direction of arrowheads in gdrawarrow does not follow the curve it
> is on.

This may be because the direction is undefined at corners of a path. MP
usually uses (postcontrol - precontrol), which doesn't usually match
either the in or the out direction. graph.mp uses instead (point -
precontrol) as the direction, generally a better choice. However, if the
path is rather curved near the head, it may seem to be incorrect, with
the edge of the head closer to the path on the inside of the curve.
Still, the head does point in the direction of the tangent at the
endpoint of the curve.

It is really quite difficult to algorithmically choose an arrowhead.
(I know, I've tried.) The best looking results can be achieved by
putting the *base* of the arrowhead (rather than the tip) at the path's
endpoint. But most people don't want to allow that.

>
> * Reading data from a file only works if there is exactly one empty line
> between data for each curve and the error message is not helpful

All graphing programs I know of require a particular format for the data
file. Some give no error and simply stop at a double blank line. One


10 Sep 08:31 2003

Re: Re: [metafont] Graph.mp annoyances

Daniel,

I know from experience that the bezier curves very different from what
was expected. And, generally I would not want to have make a curved
graph from a set of data points. However, if I would like to plot the
sine-function, it would be easier to have just a few points on it and
still have a curve.

One reason for asking was also, that there might be good reasons for the
way it was written, so please explain.

The following shows up as a polygonal curve in the .1 (and also shows a

% -90	0
% -70	0.342
% -50	0.6428
% -30	0.866
% -10	0.9848
% 0	1
% 10	0.9848
% 30	0.866
% 50	0.6428
% 70	0.342
% 90	0

beginfig(1);
draw begingraph(5cm,5cm);
gdraw "mpgraph.mp";
gdrawarrow (10,1)--(12,2); % BTW, this shows that even straigth line


10 Sep 11:16 2003

Re: latexMP

Hello Jens,

Jens-Uwe Morawski <morawski <at> gmx.net> writes:

> Please test it and give me some feedback. TIA.

OK, I did some tests, and it worked well. One thing I find quite
distracting: the position of textext is different than the one from
btex...etex:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
input latexmp;

beginfig(1);
draw unitsquare scaled 4cm;
picture p;
p :=  (btex "Hallo Welt" etex) ;
draw p;
draw bbox p;
p :=  textext ("Hallo Welt") ;
draw p;
draw bbox p;

endfig;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

IMO they both should have the anchor on the lower left. (And not in
the center like the textext). IIRC it was "OK" in the earlier version
of latexmp.mp


10 Sep 12:59 2003

Re: Re: latexMP

On Wed, 10 Sep 2003 11:16:04 +0200
Patrick Gundlach <pg <at> levana.de> wrote:

Hi Patrick,

> OK, I did some tests, and it worked well. One thing I find quite
> distracting: the position of textext is different than the one from
> btex...etex:

this can be fixed, see attached version (this version has the new syntax

but with your example i found a new problem, and i have NO idea
what exactly is the reason. The results of the below example
are ok after the 1st and 2nd MP-run. But the 3rd run suprises me -(

%%
input latexmp;
beginfig(1);
picture p;
p :=  (btex Hallo Patrick etex) ;
draw p withcolor red;
draw bbox p;
p := textext("Eine kleine Welt ist das") ;
p :=  textext ("Hallo Welt") ;
draw p;
draw bbox p;
endfig;
end
%%


10 Sep 13:45 2003

Re: latexMP (new feature)

Dear Jens-Uwe,

most of the trouble was my own mistake, so I am happy, because with the
init_numbers macro I can make any picture variable to hold the wanted
setup, so I can use it like this:
init_numbers(textext("$-$"), textext("$1$"), textext("${\times}10$"),
textext("${}^-$"), textext("${}^2$"));

However, two problems arose, but the one has already been solved by the

Second minor problem is that because of the different notation between
latexMP and verbatimtex-etex, I will not be able to do the trick of
using the same preamble in an mp-figure and the latex-file it belongs
to...or perhaps you already have a solution to this?

Regards,
Brian

Jens-Uwe Morawski wrote:
> On Tue, 09 Sep 2003 15:47:29 +0200
> Brian Elmegaard <be <at> mek.dtu.dk> wrote:
>
>
> Ahoi Brian,
>
>
>


10 Sep 15:19 2003

Re: latexMP (new feature)

On Wed, 10 Sep 2003 13:45:06 +0200
Brian Elmegaard <be <at> mek.dtu.dk> wrote:

> Second minor problem is that because of the different notation between
> latexMP and verbatimtex-etex, I will not be able to do the trick of
> using the same preamble in an mp-figure and the latex-file it belongs
> to...or perhaps you already have a solution to this?

The package i've posted includes documentation!

%% preamble.tex
\documentclass{article}
\usepackage{mflogo}
%%

%% fig.mp
setupLaTeXMP(mode=rerun,preamblefile="preamble") ;

beginfig(1);
draw textext("some text typeset using \MP{}") wthcolor red;
endfig;
end
%%

%% doc.tex
\input{preamble}
\usepackage{graphicx}
\begin{document}
\includegraphics{fig.1}
\end{document}
`