## 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.

## EXAMPLE

The following block

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

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 :

  %latexpreamble
\usepackage[latin1]{inputenc}
\usepackage{dsfont}
\usepackage{color}
%endlatexpreamble
%beginlatex 30 5
$$\textcolor{red}{\mathbf{X}} \in \mathds{R}^3$$
%endlatex

## OPTIONS

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'.

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

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

-h
Show this help and exit.

-H
Display help with a pager and exit.

mgp, http://www.mew.org/mgp/, latex and dvips.

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

 [1] http://www.mew.org/ml/mgp-users/msg00253.html
[2] http://www.csl.sony.co.jp/person/nishida/mgp-users/msg00290.html
[3] http://www.csl.sony.co.jp/person/nishida/mgp-users/msg00419.html