Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

src2(la)tex is a linux application that takes input from different commercial file formats like maple, mathematica,... notebooks and emits them as (la)tex code.

But when I feed it a certain notebook it comments on stdout that it recognizes the file to be Mathematica notebook, but the resulting latex is simply the text contents of the .nb notebook prettyfied in latex, i.e. no interpretation of graphs etc...

share|improve this question
    
You can convert Mathematica notebooks to LaTeX using Mathematica's File -> Save As ... menu item. Mathematica comes with a LaTeX style file (in SystemFiles/Include/TeX) that will let you typeset the resulting output. –  Szabolcs Jan 17 '12 at 6:59

1 Answer 1

up vote 2 down vote accepted

I do not believe that is how src2(la)tex is supposed to work. It is really just a very simple pretty printer for source code, that will allow you to insert TeX commands in your code (like formula and even images). You have to insert these in TeX format first, marking them by {\ ... }, $ ... $ or $$ ... $$, then src2(la)tex will copy them directly to the output file without pretty printing them. As far as I can tell, it cannot interpret any of the source code itself.

For example, if your source code contains:

void plot_f (float a, b) /* will plot the function $f(x) = \sqrt{x^2 - 1}$ from $a$ to $b$, 
                resulting in a plot like {\includegraphics{plot}} */
{
   /* do something */
}

it will be translated into

\documentstyle{article}
\begin{document}

\ifx\sevenrm\undefined
  \font\sevenrm=cmr7 scaled \magstep0
\fi

\newread\MyStyle
\openin\MyStyle=src2latex.s2t
\ifeof\MyStyle
  \closein\MyStyle
\else
  \input src2latex.s2t
  \closein\MyStyle
\fi

\ifx\gtfam\undefined
  \ifx\dm\undefined
    \ifx\tendm\undefined
      \def\mc{\null}
    \else
      \def\mc{\tendm}
    \fi
  \else
    \def\mc{\dm}
  \fi
  \ifx\dg\undefined
    \ifx\tendg\undefined
      \def\gt{\null}
    \else
      \def\gt{\tendg}
    \fi
  \else
    \def\gt{\dg}
  \fi
\fi
\ifx\sc\undefined
  \def\sc{\null}
\fi

\tt\mc 

\noindent
void{\tt\mc \kern0.500em}plot{\tt\_\kern.141em}f{\tt\mc \kern0.500em}(float{\tt\mc \kern0.500em}a,{\tt\mc \kern0.500em}b){\tt\mc \kern0.500em}\rm\mc {\tt /}{\tt *}\kern0.500em will\kern0.500em plot\kern0.500em the\kern0.500em function\kern0.500em $f(x) = \sqrt{x^2 - 1}$\rm\mc \kern0.500em from\kern0.500em $a$\rm\mc \kern0.500em to\kern0.500em $b$\rm\mc ,\kern0.500em 

\noindent
{\tt\mc \kern4.000em}{\tt\mc \kern4.000em}{\tt\mc \kern4.000em}\kern2.000em resulting\kern0.500em in\kern0.500em a\kern0.500em plot\kern0.500em like\kern0.500em  \includegraphics{plot} \rm\mc \kern0.500em {\tt *}{\tt /}
\tt\mc 

\noindent
{}{\tt\char'173}

\noindent
{}{\tt\mc \kern1.500em}\tt\mc {\tt /}{\tt *}\kern0.500em do\kern0.500em something\kern0.500em {\tt *}{\tt /}
\tt\mc 

\noindent
{}{\tt\char'175}

\noindent
{}

\rm\mc

\end{document}

Note that the result is in an old LaTeX 2.09 format. Changing the first line and loading the graphicx package I was then able to produce this:

result of src2latex

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.