% (mai 2009) http://www.cnam.fr/depts/maths/Membres/ghorbanzadeh/
%% Compilation avec  Miktex  : latex -enable-write18 doc.tex
%%  Attention il faut que Maple soit installé dans le répertoire : C:\Maple
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[frenchb]{babel}
\usepackage{graphicx}
\usepackage{fancyvrb}
\usepackage{verbatim}
\usepackage{multido}
\usepackage{amssymb,amscd,latexsym,amsmath,amstext}
%
\newwrite\SORTIE
\makeatletter
\newenvironment{Ecrire}[1]{%
\@bsphack
  \immediate\openout\SORTIE #1
  \let\do\@makeother\dospecials
  \catcode`\^^M\active
  \def\verbatim@processline{%
  \immediate\write\SORTIE{\the\verbatim@line}}%
  \verbatim@start}
 {\immediate\closeout\SORTIE
 \@esphack
  }
\makeatother
%%%%%%%%%%%%%%%%
% #1 fichier contenant les commandes Maple
% #2 fichier sortie  en format LaTeX
\newcommand{\ExecutMaple}[2]{%
\immediate\write18{C:/Maple/bin.win/cmaple -q  #1 >#2}
}

\pagestyle{empty}

\renewcommand{\arraystretch}{1.5}

\begin{document}


\begin{Ecrire}{test.mws}
restart:
  with(student):
Formulaire := proc(f)
[f,simplify(diff(f,x)),simplify(int(f,x))+C]:
end proc:
L[1]:=Formulaire(x^3):
L[2]:=Formulaire(exp(a*x)):
L[3]:=Formulaire(ln(x)):
L[4]:=Formulaire(sin(x)):
L[5]:=Formulaire(cos(x)):
L[6]:=Formulaire(tan(x)):
L[7]:=Formulaire(cot(x)):
L[8]:=Formulaire(arccos(x)):
L[9]:=Formulaire(arcsin(x)):
L[10]:=Formulaire(arctan(x)):
L[11]:=Formulaire(x/sqrt(1-x^2)):
L[12]:=Formulaire(sin(x)/(1+cos(x))):
L[13]:=Formulaire(cos(x)/(1+sin(x))):
L[14]:=Formulaire(1/(exp(x)+exp(-x))):
L[15]:=Formulaire(1/(exp(x)-exp(-x))):
x2:="\\\\\\hline":
x3:="&":


printf("\\[\\begin{array}{|c|c|c|}\\hline\n");
printf("\\text{fonctions} & \\text{d\\'eriv\\'ees} & \\text{primitives} \\\\\\hline\n");
printf("f(x) & f^{\\prime}(x) & \\int f(x)\\,dx \\\\\\hline\n");
  for i from 1 by 1 to 15 do
cat(cat(cat(cat(cat(printf("%Q",latex(op(1,L[i]))),printf("%s",x3)),printf("%Q",latex(op(2,L[i])))),printf("%s",x3)),printf("%Q",latex(op(3,L[i])))),printf("%s",x2)):
  end do;
  printf("\\end{array}\\]");
  Quit:
\end{Ecrire}


% Appel à Maple
\ExecutMaple{test.mws}{test.tex}
\input{test.tex}

\end{document}