Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to use figures created with metapost in a TeX document compiled with pdflatex, but I have some troubles. I did as advised here, but it fails!

My code is this :

\documentclass[10pt]{article}  
\usepackage{graphics}  
\begin{document}  
\includegraphics{figures/TryMetaPost.1}  
\end{document}

With plain latex I have no problem but with pdflatex I obtained:

LaTeX Error: Unknown graphics extension: .1

I tried also with .mps and in this case I have (with pdflatex)

Cannot convert figures/TryMetaPost1.mps from MPS to PDF

Does anybody see my mistake?

share|improve this question
    
possible duplicate of \includegraphics: Dots in filename –  diabonas Mar 18 '12 at 18:01
add comment

2 Answers 2

The first message simply means that pdfLaTeX doesn't know the extension. You can get around this problem either by changing the extension to .mps or by declaring a rule:

\DeclareGraphicsRule{.1}{mps}{*}{}

The second message is more problematic: It indicates that pdflatex has problems to convert the mps. Which means that either the mps itself is broken or something doesn't work in your system. Could you show the offending mps and the log-file?

share|improve this answer
    
I will search in this way. I think the problem comes from the fact that I have only version 0.993 of mpost. What do you think? –  PanAkry Mar 19 '12 at 8:31
    
I will certainly not start to guess around without some more reliable informations. And if you have an old mpost everything else is probably old too. So don't look only in one direction. –  Ulrike Fischer Mar 19 '12 at 8:35
    
The log file (metapost) LaTeX Error: Missing \begin{document}. l.12 / bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd ? ! Emergency stop. ... l.12 / bd{bind def}bind def/fshow {exch findfont exch scalefont setfont show}bd –  PanAkry Mar 19 '12 at 8:43
2  
Don't send information snippets. Make a complete example, with a tex-file, the mp, the resulting mps and the complete log-file in a zip-file and put them somewhere for download. –  Ulrike Fischer Mar 19 '12 at 8:46
add comment

Adding \DeclareGraphicsRule{.1}{mps}{*}{} to a tex file works for pdflatex, which is OK with respect to the subject of this question. But it has the side-effect of breaking latex, because mps is not a pre-defined file extension for latex. To circumvent this, one should check for the actual TeX engine used, e.g.,

\usepackage{ifpdf}
\ifpdf
  \DeclareGraphicsRule{*}{mps}{*}{}
\fi

The MetaPost manual suggests another method, though. Recent MetaPost versions have a file name template mechanism that can be used to change the format of MetaPost output file names. Adding the line

outputtemplate := "%j-%c.mps";

to the preamble of a MetaPost input file named figs.mp, makes output files have names figs-1.mps, figs-2.mps etc. Files ending mps can easily be included in LaTeX documents by giving the full name to \includegraphics like

\includegraphics{figs-1.mps}

This works with latex as well as pdflatex without messing with \DeclareGraphicsRule. See the MetaPost manual and Keith Reckdahl's Using Imported Graphics in LaTeX and pdfLaTeX for why that works.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.