[Tex/LaTex] Metapost use venn package

metapost

I use TexShop, and I have successfully compiled an example which uses metapost code directly in LaTeX code ( by running pdflatex, then metapost, then finally pdflatex again).
this code uses mpfic option

Now I want to use the venn ( http://ctan.org/tex-archive/graphics/metapost/contrib/macros/venn ) package in my document. But \usepackage{venn} is causing not found error, and any command without venn package is not working as well.

So how do I setup the usage of venn package with metapost. I have installed it already using TeX live utility.

Best Answer

I have never tried to include the source directly inside the .tex file but in case your trouble is with the metapost code it may help to start with a known-good stand-alone source.

I did this recently, so I suspect that it still works (although I have edited out some stuff I think is not needed so do let me know if it fails). Here is the input file. It draws the Venn diagram for the union.

% set.mp
%  MetaPost input file with chapter one pictures.
verbatimtex
%&latex
\documentclass{book}
\begin{document}
etex

input venn

outputtemplate := "%j-%2c.mps";
beginfig(0);
  draw_venn_two(false,true,true,true);
  % Label the sets (from pp 29 pf MetaPost manual)
  picture pa, pb;
  pa = thelabel(btex \tiny $A$ etex,   (.9venn_circle_left_shift,1.15venn_circle_top_shift));
  pb = thelabel(btex \tiny $B$ etex, (1.1venn_circle_right_shift,1.15venn_circle_top_shift));
  unfill bbox pa;
  draw pa;
  unfill bbox pb;
  draw pb;
endfig;

end

At a (Linux) command line I ran the four commands

  • mpost set.mp followed by
  • tex mproof set-00.mps followed by
  • dvips -Pwww -omproof.ps mproof finally followed by
  • gv mproof.ps;

this last pops up a viewer for the figure.

To include it in my doc I used this.

\begin{center}
  \includegraphics[width=0.33\textwidth]{set-00.mps}
\end{center}

This is inside Beamer. I don't see that I did anything special to get the graphicx system to recognize the .mps ending but I may have forgot the details; let me know.

(Edit: someone changed what I wrote and in particular dropped the necessary initial paragraph. I added something like it back.)

Related Question