function latex(s,filename)
%LATEX	LaTeX represention of symbolic output.
%	LATEX(S) prints the LaTeX representation of S.
%	LATEX(S,'filename') also prints it to the specified file.
%
%	Example:
%	    r = '(1+2*x+3*x^2)/(4+5*x+6*x^2)'
%	    latex(r)
%	  
% 	    {\frac {1+2\,x+3\,x^{2}}{4+5\,x+6\,x^{2}}} 	  
%
%	    H = hilb(3);
%	    latex(H,'hilb.tex')
%
%	    \left [\begin {array}{ccc} 1&1/2&1/3\\\noalign{\medskip}1/2&1/3&1/4
%	    \\\noalign{\medskip}1/3&1/4&1/5\end {array}\right ]
%
%	See also PRETTY.

%	Copyright (c) 1993-95 by The MathWorks, Inc.
%	$Revision: 1.4 $  $Date: 1995/03/01 21:38:52 $

if nargin > 1, diary(filename); end
if ~isstr(s), s = sym(s); end
if s(1) == '[', s = sm2ar(s); end
% Use maplemex directly to print multiple line output.
maplemex(['latex(' s ');'],1)
if nargin > 1, diary('off'); end
