NAME mgplatex - Compile latex code embedded in MagicPoint code

Creates a MagicPoint file.mgp from a file containing MagicPoint code with inlined LaTeX code.

SYNOPSIS mgplatex [options] file

Reads file, transforms LaTeX code enclosed in each %beginlatex-%endlatex, \beginlatex-\endlatex or %latexline-%endlatexline block into equivalent mgp code and writes the result in file.mgp, which is readable by mgp.

In the process, a directory is created (default : file.auxfiles), in which .tex files -one per block of latex code- are created and transformed into encapsulated postscript (.eps) images by latex and dvips.

The arguments following %beginlatex are the width and height (in screen percents) of the latex text and are passed to the mgp command %image that is used to display the LaTeX output.

A %latexline block behave the same as %beginlatex block except that the latex code is displayed on the same line as the preceding and following magicpoint code. This is useful for embedding small amounts of latex code in paragraphs.

If a %latexpreamble-%endlatexpreamble block is present, it is inserted before \begin{document}. By default, \usepackage[latin1]{inputenc} is inserted.

If a %latexinit-%endlatexinit block is present, it is inserted between \begin{document} and the code defined by each %beginlatex-%endlatex block. By default, nothing is instered.


The following block

  %beginlatex 60 30
  A little bit of \LaTeX : 
  \[ A(x) = \int_{0}^{\infty} e^-\frac{x}{2} dx \]

is transformed by mgplatex into :

  %image "file.auxdir/latex-0.eps" 60 35

where file.auxdir/latex-0.eps is the image resulting from running latex and dvips on the latex code.

It is possible to use latex packages by specifying them in preamble. The following example uses the color and dsfont packages :

  %beginlatex 30 5
    $$ \textcolor{red}{\mathbf{X}} \in \mathds{R}^3 $$


Options can be grouped together.

-d dirname
Put generated files in dirname. By default, uses file.auxfiles.

-o outfile
Call outfile the resulting .mgp file. By default, the name is obtained by removing an eventual '.mgplatex' suffix of file and appending '.mgp'.

Force compilation of all latex files. By default, a latex file is compiled only if it has been modified.

Be verbose : say what's going on and show output of latex and dvips. More -v options produce more verbose output.

Show this help and exit.

Display help with a pager and exit.


mgp,, latex and dvips.

Embedding latex in mgp is an old wheel that is often reinvented on Luigi Rizzo made a on-the-fly preprocessor [1] and so did Stephan Buchert [3], who modified an the script by Sylvain Pion. Anders Logg made an offline preprocessor mgptex [2]. mgplatex should be able to read the embedded code of mgptex.


COPYRIGHT Etienne Grossmann <>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.