Generalemp | Embedding MetaPost Code in Document

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Diff Eq
Posts: 7
Joined: Tue Sep 04, 2007 4:09 pm

emp | Embedding MetaPost Code in Document

Post by Diff Eq »

Hey guys,

I've been trying to figure out how to insert MetaPost code in a LaTeX document to creat some simple graphics.

The emp documentation states:
emp: The emp environment contains the description of a single figure that will be
placed at the location of the environment. Required arguments are the width
and the height of the figure, in units of \unitlength. They will be available as
the METAPOST variables w and h. The optional argument assigns a name to be
used with \empuse{hnamei}.

Code: Select all

\begin{emp}[name](width,height)
  METAPOST-commands
\end{emp}
Compiling this causes an error
I detected a emp environment outside of empfile
and nothing is displayed.

Can anyone nudge me in the right direction on trying to get this resolved?

Thanks!

PS, I'm using the recent MiKTeX/TeXnicCenter installations - I saw that there's "mpost" in the MiKTeX documentation that allows you to insert MetaPost images into the document, so, if things don't get resolved here I'll move over to the other forum.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

emp | Embedding MetaPost Code in Document

Post by localghost »

The emp documentation also states (in the paragraph right before):
All descriptions that should go into one METAPOST file are placed inside a empfile environment which takes the name of the METAPOST file as an optional argument:

Code: Select all

\begin{empfile}[METAPOST-file]
 …
\end{empfile}
The default METAPOST-filename is \jobname.mp.

So, you simply have to embed the emp environment in the empfile environment. And that's exactly what the error message is meaning.

Code: Select all

\begin{empfile}[METAPOST-file]
  \begin{emp}[name](width,height)
    …
  \end{emp}
\end{empfile}
Of course, you can put more than one emp environment into an empfile. This is very similar to what the egplot package provides for GNUplot.
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]

¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Post Reply