Rogério Brito <[EMAIL PROTECTED]> wrote: > Sorry for the use of wrong names. They should all have been > metapost-fail in the examples above.
I understood that. >> Here, with texlive-metapost version 2007-12.np.etch.1, including the >> compiled figure in a LaTeX document processed by pdfTeX works fine. > > Which steps did you actually use? I'm curious. I tried to grab > metapost-fail.pdf and include it with \includegraphics (with the > graphicx package loaded) and I got a blank place where the square should > have appeared, unfortunately. :-( pdfTeX is able (thanks to Hans Hagen) to include MetaPost output files. You don't need (and shouldn't) convert them to PDF beforehand. Just give them the extension .mps and graphicx will do the rest. For the extension thing, I usually create symlinks from schema1.mps to schema.1, schema2.mps to schema.2, etc. so that I can write \includegraphics*{schema7} in my main LaTeX document. So, the steps are: 1. TEX=latex mpost rbrito.mp (where rbrito.mp is the file you provided) 2. ln -s rbrito.1 rbrito.mps 3. cat >essai.tex <<EOF \documentclass[a4paper,12pt,pdftex]{article} \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} \usepackage{textcomp} \usepackage{graphicx} \begin{document} \begin{center} \includegraphics*{rbrito} \end{center} \end{document} EOF 4. pdflatex essai.tex > What exactly did you use to convert the picture to PDF? If I remember > correctly, epstopdf crashes with a problem of ghostscript. Don't convert the picture. Unless you use the prologues variable, output files from MetaPost are incomplete PostScript files (something about the fonts is missing), so the conversion is not straightforward. BTW, I suppose that the .mps extension means "MetaPost PostScript" precisely to remind us that these are not really PostScript files. > Oh, it just occurred me that the versions of ghostscript that we may be > using may be the culprit. I didn't use gs at all here. > But I am not exactly shure, unfortunately. Any light shed on this issue > would be *quite* welcome. I'm pretty sure it's not a MetaPost problem. BTW, it is IMHO clumsy to require the setting of TEX to "latex" for your MetaPost documents to compile. Other documents may well require TEX=tex, so you would have to fiddle with the env var depending on the document. Bleh. Personally, I declare the use of LaTeX where it belongs, i.e. in the .mp file, like this: ,----[ schemas.mp ] | verbatimtex | %&latex | \documentclass[a4paper,12pt,frenchb,french]{article} | \usepackage{lmodern} | \usepackage[T1]{fontenc} | \usepackage[latin1]{inputenc} | \usepackage{xspace} | \usepackage[thinspace]{SIunits} | \usepackage{babel} | | \NoAutoSpaceBeforeFDP | \FrenchItemizeSpacingtrue | \FrenchListSpacingtrue | | % Pour écrire AB, (AB), [AB], etc. | \newcommand{\pts}[1]{\ensuremath{\mathit{#1}}} | | \begin{document} | etex | | beginfig(1); | numeric u; | pair a, b, m, i; | | [...] | | endfig; | | verbatimtex | \end{document} | etex | end `---- I'm also attaching a typical Makefile I use whose purpose is to: - compile a simple TeX document containing all figures created from schemas.mp (this is used for "developping" the figures); - automatically create the .mps symlinks needed for the inclusion of the MetaPost output files. To use this Makefile, you need: - a simple LaTeX file 'essai.tex' as attached; - a file named 'schemas.mp' containing your MetaPost figures; - to adjust NUMBER_OF_SCHEMAS in the Makefile to match the number of figures in schemas.mp (yes, this could be extracted automatically...). - same thing with \setcounter{NumberOfFigures}{15} in essai.tex.
all: pdf MP_BASE_NAME := schemas MP_STEM := schema NUMBER_OF_SCHEMAS := 15 LATEX_ARGS := --src-specials \\nonstopmode PDFLATEX_ARGS := \\nonstopmode TEX_RUNS := 1 SRC_BASE_NAME := essai SRC := $(SRC_BASE_NAME).tex SRC_PDF_BASE_NAME := $(SRC_BASE_NAME)_pdf SRC_PDF := $(SRC_PDF_BASE_NAME).tex SRC_PS_BASE_NAME := $(SRC_BASE_NAME)_ps SRC_PS := $(SRC_PS_BASE_NAME).tex DVI := $(SRC_PS_BASE_NAME).dvi COMPILED_SCHEMAS := $(foreach num, $(shell seq 1 $(NUMBER_OF_SCHEMAS)), \ $(MP_BASE_NAME).$(num)) $(COMPILED_SCHEMAS): $(MP_BASE_NAME).mp mpost $(MP_BASE_NAME).mp $(MP_STEM)%.mps: $(MP_BASE_NAME).% @if [ ! -e '$@' ]; then \ ln -s '$<' '$@'; \ fi $(MP_STEM)%.eps: $(MP_BASE_NAME).% @if [ ! -e '$@' ]; then \ ln -s '$<' '$@'; \ fi pdf: $(SRC_PDF) $(foreach num, $(shell seq 1 $(NUMBER_OF_SCHEMAS)), \ $(MP_STEM)$(num).mps) for i in `seq 1 $(TEX_RUNS)`; do \ pdflatex $(PDFLATEX_ARGS)'\input{$<}'; \ done @if [ ! -e '$(SRC_BASE_NAME).pdf' ]; then \ ln -s '$(SRC_PDF_BASE_NAME).pdf' '$(SRC_BASE_NAME).pdf'; \ fi ps: $(DVI) dvips -o '$(SRC_BASE_NAME).ps' '$<' dvi: $(DVI) $(DVI): $(SRC_PS) $(MP_STEM)1.eps for i in `seq 1 $(TEX_RUNS)`; do \ latex $(LATEX_ARGS)'\input{$<}'; \ done @if [ ! -e '$(SRC_BASE_NAME).dvi' ]; then \ ln -s '$(SRC_PS_BASE_NAME).dvi' '$(SRC_BASE_NAME).dvi'; \ fi $(SRC_PS): $(SRC) replace-in-file.py --from="*FloTeXDriver*" --to=dvips --maxrepl=1 \ '--output=$@' '$<' $(SRC_PDF): $(SRC) replace-in-file.py --from="*FloTeXDriver*" --to=pdftex --maxrepl=1 \ '--output=$@' '$<' clean: rm -f '$(SRC_PDF)' '$(SRC_PS)' '$(DVI)' '$(SRC_PDF_BASE_NAME).pdf' \ missfont.log for ext in dvi ps pdf; do \ rm -f '$(SRC_BASE_NAME).'"$$ext"; \ done for basename in '$(SRC_PS_BASE_NAME)' '$(SRC_PDF_BASE_NAME)'; do \ for ext in aux log ind; do \ rm -f "$${basename}.$${ext}"; \ done; \ done # Metapost-generated files rm -f $(MP_BASE_NAME).log $(MP_BASE_NAME).mpx find . -type f -regex '\./$(MP_BASE_NAME)\.[0-9]+$$' -print0 | \ xargs -0r rm find . -type l -regex '\./$(MP_STEM)[0-9]+\.[me]ps$$' -print0 | \ xargs -0r rm .PHONY: all clean pdf dvi ps
\documentclass[a4paper,11pt,frenchb,french,*FloTeXDriver*]{article} \usepackage{lmodern} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} \usepackage{xspace} \usepackage{ifthen} \usepackage{calc} \usepackage[nohead,left=2.5cm,right=2.5cm,top=2.3cm,bottom=2cm]{geometry} \usepackage{graphicx} %\usepackage{array} \usepackage{babel} \NoAutoSpaceBeforeFDP \FrenchItemizeSpacingtrue \FrenchListSpacingtrue \title{Schémas faits avec MetaPost} \author{Florent \bsc{Rougon}} %\pagestyle{empty} \newcounter{Counter} \newcounter{NumberOfFigures} \begin{document} \setlength{\parindent}{0pt}% %\setlength{\parskip}{\baselineskip}% \begin{center} \setcounter{NumberOfFigures}{15}% \setcounter{Counter}{0}% \whiledo{\value{Counter} < \value{NumberOfFigures}}{% \stepcounter{Counter}% \includegraphics*{schema\theCounter}% \bigskip\par }% \end{center} \end{document}
Since this generates a lot of files, I usually put all this in a "pictures" subdirectory (actually, "images") that is indicated like that in the main document preamble: \graphicspath{{pictures/}} (and I don't give a rat's ass that using \graphicspath eats some tiny bit of TeX memory as usually stated on the LaTeX FAQs) HTH. -- Florent