exported figures from DIA to Metapost including in document
Hi All! I'm in beginning to write a thesis in physics(undergraduate level) and one of many things I wanna do is, cause I create much illustrations in DIA http://www.gnome.org/projects/dia/ and the program can export to figure.mp, to include these in my document. I've read the instructions on http://wiki.contextgarden.net/Mpgraphic I do not get this working. How is the best way to accomplish this? The reason is why I want to do in this way is to input tex code in the figure (especially math and symbol definitions) and optionally place them in specific places inside the figure. By this method I can even do better illustrations, hopefully. My workflow has been like this: 1. Create the desired figure in DIA and choose the export option. TeX metapost *.mp(see attached file ). 2. Tryed to do inclusion in a TeX-document like this \startstaticMPfigure{magflux} the code in the attached file \stopstaticMPfigure \starttext Here is my figure \usestaticMPfigure[magflux][width=0.8\textwidth] \stoptext But it fails with errormessage: !Paragraph ended before \startstaticMPfigure was complete ..... Should I place part of the code in some definitions? 3. To input textlabels in mathnotation optionally anywhere I want inside the figure. And also do something like \placefigure[][fig:metapostfigure]{Here is the figure I made in DIA converted to metapost}{\usestaticMPfigure[magflux][width=0.8\textwidth]} so it also can be referred to in the text. All best and thanks in advance! Janneman -- TeX Engine : LuaTeX current version: 2008.10.23 17:32 OS : Ubuntu 8.10 Intrepid Ibex
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
Hi All!
I'm in beginning to write a thesis in physics(undergraduate level) and one of many things I wanna do is, cause I create much illustrations in DIA http://www.gnome.org/projects/dia/ and the program can export to figure.mp, to include these in my document.
I've read the instructions on http://wiki.contextgarden.net/Mpgraphic
I do not get this working. How is the best way to accomplish this?
See the attached file. Dia exports the figure with verbatimtex &latex etex which tells metapost to run labels through latex. I guess that this is what causes the errors. If you simply remove some of the boiler plate, the figure compiles fine (see attached file)
The reason is why I want to do in this way is to input tex code in the figure (especially math and symbol definitions) and optionally place them in specific places inside the figure. By this method I can even do better illustrations, hopefully.
My workflow has been like this:
1. Create the desired figure in DIA and choose the export option. TeX metapost *.mp(see attached file ).
2. Tryed to do inclusion in a TeX-document like this
\startstaticMPfigure{magflux} the code in the attached file \stopstaticMPfigure
\starttext
Here is my figure \usestaticMPfigure[magflux][width=0.8\textwidth]
\stoptext
But it fails with errormessage:
!Paragraph ended before \startstaticMPfigure was complete .....
Should I place part of the code in some definitions?
I do not get this error, but staticMPfigure is not working for me. I would recomment not to use staticMPfigure, rather use useMPfigure. (I had asked Hans for staticMPfigure a few years ago when TeX-MP interaction was slow. Now, with MPLib I do not think that we need the staticMPfigure mechanism. Personally, I haven't used it for a while) I also had to add save x, y, t, p ; %%%% Added this line to include the figure multiple times (or to include multiple figures, I would imagine). Aditya
mån 2008-11-24 klockan 09:08 -0500 skrev Aditya Mahajan:
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
Hi All!
I'm in beginning to write a thesis in physics(undergraduate level) and one of many things I wanna do is, cause I create much illustrations in DIA http://www.gnome.org/projects/dia/ and the program can export to figure.mp, to include these in my document.
I've read the instructions on http://wiki.contextgarden.net/Mpgraphic
I do not get this working. How is the best way to accomplish this?
See the attached file. Dia exports the figure with verbatimtex &latex etex
which tells metapost to run labels through latex. I guess that this is what causes the errors. If you simply remove some of the boiler plate, the figure compiles fine (see attached file)
The reason is why I want to do in this way is to input tex code in the figure (especially math and symbol definitions) and optionally place them in specific places inside the figure. By this method I can even do better illustrations, hopefully.
My workflow has been like this:
1. Create the desired figure in DIA and choose the export option. TeX metapost *.mp(see attached file ).
2. Tryed to do inclusion in a TeX-document like this
\startstaticMPfigure{magflux} the code in the attached file \stopstaticMPfigure
\starttext
Here is my figure \usestaticMPfigure[magflux][width=0.8\textwidth]
\stoptext
But it fails with errormessage:
!Paragraph ended before \startstaticMPfigure was complete .....
Should I place part of the code in some definitions?
I do not get this error, but staticMPfigure is not working for me. I would recomment not to use staticMPfigure, rather use useMPfigure.
(I had asked Hans for staticMPfigure a few years ago when TeX-MP interaction was slow. Now, with MPLib I do not think that we need the staticMPfigure mechanism. Personally, I haven't used it for a while)
I also had to add
save x, y, t, p ; %%%% Added this line
to include the figure multiple times (or to include multiple figures, I would imagine).
Aditya Thanks to all answers. I got it work, though a minor problem left, it seems that "calligraphy" is not working.
line 108 draw btex { $ \vec{\cal B }$} etex..... see the new attached file. Janneman
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
Thanks to all answers. I got it work, though a minor problem left, it seems that "calligraphy" is not working.
line 108 draw btex { $ \vec{\cal B }$} etex.....
see the new attached file.
If you are using MKII (running context using texexec filename), then do not use btex ... etex.[1] Use \sometxt{...} instead. I just used the following regex on your file %s/btex\s*\(.\)\s*etex/\\sometxt\1/g and then everything works fine. [1] It is possible to get correct fonts using btex ... etex also. You need to set up fonts in \startMPenvironment ... \stopMPenvironment. For most cases \sometxt is more convinient. Aditya
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
Thanks to all answers. I got it work, though a minor problem left, it seems that "calligraphy" is not working.
line 108 draw btex { $ \vec{\cal B }$} etex.....
see the new attached file.
If you are using MKII (running context using texexec filename), then do not use btex ... etex.[1] Use \sometxt{...} instead. I am using MKIV I just used the following regex on your file %s/btex\s*\(.\)\s*etex/\\sometxt\1/g and then everything works fine. This above I didn't understood. I did though replace with \sometxt{\vec{\cal B}} but no effect.
[1] It is possible to get correct fonts using btex ... etex also. You need to set up fonts in \startMPenvironment ... \stopMPenvironment. For most cases \sometxt is more convinient.
Aditya I tried to do some fontsettings, maybe it was the wrong way setting up
mån 2008-11-24 klockan 10:40 -0500 skrev Aditya Mahajan: things. You can see in the updated file. Janneman -- TeX Engine : LuaTeX current version: 2008.10.23 17:32 OS : Ubuntu 8.10 Intrepid Ibex
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
I tried to do some fontsettings, maybe it was the wrong way setting up things. You can see in the updated file.
This is not your fault. There is a bug in MKIV definition of \cal. Test example: \starttext \startMPcode draw \sometxt{$\cal B$} ; \stopMPcode \stoptext does not give caligraphic B. For the time being, you can use a work-around of adding \noexpand before \cal. \starttext \startMPcode draw \sometxt{$\noexpand\cal B$} ; \stopMPcode \stoptext Hans, Taco: Is it OK to add \unexpanded in the definition of cal \unexpanded\def\cal{\mathortext{\fam\purefamily{calligraphic}}{\symbolicfont{Calligraphic}}} Aditya
It worked! Thanks a lot! mån 2008-11-24 klockan 16:23 -0500 skrev Aditya Mahajan:
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
I tried to do some fontsettings, maybe it was the wrong way setting up things. You can see in the updated file.
This is not your fault. There is a bug in MKIV definition of \cal. Test example:
\starttext \startMPcode draw \sometxt{$\cal B$} ; \stopMPcode \stoptext
does not give caligraphic B. For the time being, you can use a work-around of adding \noexpand before \cal.
\starttext \startMPcode draw \sometxt{$\noexpand\cal B$} ; \stopMPcode \stoptext
Hans, Taco: Is it OK to add \unexpanded in the definition of cal
\unexpanded\def\cal{\mathortext{\fam\purefamily{calligraphic}}{\symbolicfont{Calligraphic}}} Can this line above be copied and pasted in to my personal "module" file?
Aditya
Cheers Janneman
On Mon, 24 Nov 2008, Jan-Erik Hägglöf wrote:
\unexpanded\def\cal{\mathortext{\fam\purefamily{calligraphic}}{\symbolicfont{Calligraphic}}} Can this line above be copied and pasted in to my personal "module" file?
For the time being, you should add this to your personal configuration. Aditya
Aditya Mahajan wrote:
Hans, Taco: Is it OK to add \unexpanded in the definition of cal
\unexpanded\def\cal{\mathortext{\fam\purefamily{calligraphic}}{\symbolicfont{Calligraphic}}}
I think so. It makes sense to have \unexpanded before every macro that executes an unexpandable primitive command, as these will never be expanded correctly anyway. Best wishes, Taco
Hi Jan-Erik, Jan-Erik Hägglöf schrieb:
Hi All!
I'm in beginning to write a thesis in physics(undergraduate level) and one of many things I wanna do is, cause I create much illustrations in DIA http://www.gnome.org/projects/dia/ and the program can export to figure.mp, to include these in my document.
I've read the instructions on http://wiki.contextgarden.net/Mpgraphic
I do not get this working. How is the best way to accomplish this?
The reason is why I want to do in this way is to input tex code in the figure (especially math and symbol definitions) and optionally place them in specific places inside the figure. By this method I can even do better illustrations, hopefully.
My workflow has been like this:
1. Create the desired figure in DIA and choose the export option. TeX metapost *.mp(see attached file ).
1.1 remove all latex related code from the mp file verbatimtex %&latex \documentclass{minimal} \begin{document} etex
2. Tryed to do inclusion in a TeX-document like this
\startstaticMPfigure{magflux} the code in the attached file \input magfluxdensity.mp \stopstaticMPfigure
\starttext
Here is my figure \usestaticMPfigure[magflux][width=0.8\textwidth]
\stoptext
But it fails with errormessage:
!Paragraph ended before \startstaticMPfigure was complete .....
Should I place part of the code in some definitions?
3. To input textlabels in mathnotation optionally anywhere I want inside the figure.
\startMPenvironment[global] ... global font defintions (esp. a math font), so metapost can also use them \stopMPenvironment Hope that helps... Best wishes, Peter
And also do something like
\placefigure[][fig:metapostfigure]{Here is the figure I made in DIA converted to metapost}{\usestaticMPfigure[magflux][width=0.8\textwidth]}
so it also can be referred to in the text.
All best and thanks in advance!
Janneman
------------------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (4)
-
Aditya Mahajan
-
Jan-Erik Hägglöf
-
Peter Rolf
-
Taco Hoekwater