Graphics, Figures & Tablesgetting emp to work with MiKTeX and TeXnic

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

getting emp to work with MiKTeX and TeXnic

Post by maja z »

OK, complete selftaught newbie here, got a bit lost...

I'm running MiKTeX 2.7 with TeXnicCenter 1.0.

I thought (for some obscure reason) that I should try to include my graphics as metapost code directly in my .tex file.

So I start with a simple example, looking something like this:

Code: Select all

\documentclass{article}
\usepackage{emp}
\begin{document}

\begin{figure}
\centering
\begin{empfile}
  \begin{emp}(0, 0)
  draw unitsquare scaled 70;
  draw (30,40) withpen pencircle scaled 4;
  pickup pencircle scaled 8;
  draw (40,50);
  draw (50,60);
\end{emp}
\end{empfile}
\caption{jebemjimsunce}
\end{figure}

\end{document}
Of course this didn't work in the slightest, and it took me a while to realise that I had to create a new output profile that had metapost (mp.exe) as a postprocessor as well as Latex=>DVI run again. So OK, I've got this far.

Then I figured out that LaTeX => MP => PDF would also work, if I added \usepackage{graphicx}
\DeclareGraphicsRule{*}{mps}{*}{}
to the preamble.

OK, so now I've hit a wall with all my googling, here are my two problems:

1. How do I include multiple figures using the code I have above? The .mp file that is produced has the same name as my .tex file. I understand that empfile can also name the file, so I could give each figure a different file name, but then I don't understand how to get the postprocessor to pick up the right files... argh, I know I'm beign stupid here...

2. OK, let's stay with one figure, but add the line
dotlabel.bot(btex is this working etex, (30,40));
I get an error saying
!Undefined control sequence.
1.1 \documentclass [10pt]{article}
?tex: Bad file descriptor
Creating C:\PROGRA~1\MIKTEX~1.mpx...
makempx:"tex -parse-first-line" failed on C:\DOCU..........\mpx314.tex.
mp.exe: The operation failed for some reason.
The .mp file is created, but not the .1 file, and so no figure...
BUT, if I manually open the .mp file and add %&latex into the third line (just after verbatimex) and then manually run mp, the .1 file is created perfectly and can be included in the .tex file with \includegraphics. But of course then why bother with emp anyway

I apologise for not being articulate in these matters, I hope whoever will be willing to reply will have figured out my level of understanding, and explain at an appropriate level :)

Thanks!

Maja

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

getting emp to work with MiKTeX and TeXnic

Post by localghost »

I saved your example as 'emp-xmpl.tex' and started a run. A look into the log file reveals the reasons for the missing MetaPost figure.

Code: Select all

emp: File emp-xmpl.1 not found:
emp: Process emp-xmpl.mp with MetaPost and then reprocess this file.
Thus a simple line on the command prompt will do that.

Code: Select all

mpost emp-xmpl.mp
The call of MetaPost can differ on other systems (perhaps 'mp' instead of 'mpost'). It leaves me with a file called 'emp-xmpl.1' which is included after another run of the latex compiler.

You can add the call of MetaPost in the post-processing section of an output profile in TeXnicCenter (TXC). But this is not very flexible in case there are many MetaPost figures in different files. This work could be simplified by linking the *.mp endings to MetaPost. So a simple double click on an icon would execute MetaPost and generate the necessary file.

The egp package works in exactly the same way for Gnuplot. I used it earlier before the gnuplottex package was developed (perhaps somebody has the idea to port and adapt that package to MetaPost as 'metaposttex' in the future).

Nowadays for such graphics and even plots I rely on pgf/tikZ, which has a syntax very similar to that of MetaPost. Some time ago I used PSTricks. Others use Asymptote.


Best regards and welcome to the board
Thorsten
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

Re: getting emp to work with MiKTeX and TeXnic

Post by maja z »

Thorsten, thanks for that!

Although I'm not sure I was clear enough - the code that you ran, did you also add the line with the btex..etex call?
The example that I posted works OK for me, like you said, I have the call to mp.exe in the postprocessing section. But as soon as I add a label and want the text to be processed by LaTeX (i.e. using btex ... etex) I get an error.

I guess my wider question is whether using emp is a sensible way forward for a large project e.g. thesis, with dozens of metapost graphics. Or should I simply run mp on them outside LaTeX and then include them as graphic files?

Maja
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

getting emp to work with MiKTeX and TeXnic

Post by localghost »

It seems that I should have read your request more carefully. I don't know what you call 'btex...etex' so I need an explanation for that. I simply did the MetaPost processing and another latex run.
maya z wrote:[...] I guess my wider question is whether using emp is a sensible way forward for a large project e.g. thesis, with dozens of metapost graphics. Or should I simply run mp on them outside LaTeX and then include them as graphic files? [...]
I guess that I pointed out some alternatives in my last reply. If you want to stay with MetaPost, then linking the files to MetaPost (right click and 'Open with' in the context menu) could be a suitable solution.
maja z
Posts: 18
Joined: Mon May 18, 2009 8:53 pm

getting emp to work with MiKTeX and TeXnic

Post by maja z »

Sorry if I wasn't clear; as I said I am new at this and tend to randomly google/stumble myself through.
Anyway, Andre Heck's "Learning Metapost by Doing" (p.21 ff) is at least one instance of this code, namely the btex... etex construct is meant to pass the text in between to TeX for typesetting?
So my idea was to get graphics (with text) that would "fit in" with the rest of my text, by also being typeset by TeX. And this is essentially my main reason for fiddling around like I am with metapost, perhaps there is a simpler way of acheiving the same thing? (actually most of my graphics are from R, so I'm not sure how that would work anyway).
Thanks!
Maja
Post Reply