# Saving in Latex

I have already asked this question in another topic, see here. When I save the following notebook code as $\LaTeX$,

In[1]:= DSolve[y'[x] + x y'[x]^2 == 1, y, x]

Out[1]= {{y ->
Function[{x},
C[1] + 1/2 (-2 Sqrt[1 + 4 x] - 2 Log[1 - Sqrt[1 + 4 x]])]}, {y ->
Function[{x},
C[1] + 1/2 (2 Sqrt[1 + 4 x] - 2 Log[1 + Sqrt[1 + 4 x]])]}}


I get this latex code:

%% AMS-LaTeX Created by Wolfram Mathematica 8.0 : www.wolfram.com

\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}
\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}[1]{{}}
\newcounter{mathematicapage}
\begin{document}
\begin{doublespace}
\noindent$$\pmb{\text{DSolve}[y'[x]+x y'[x]{}^{\wedge}2==1,y,x]}$$
\end{doublespace}
\begin{doublespace}
\noindent$$\left\{\left\{y\to \text{Function}\left[\{x\},C[1]+\frac{1}{2} \left(-2 \sqrt{1+4 x}-2 \text{Log}\left[1-\sqrt{1+4 x}\right]\right)\right]\right\},\left\{y\to \text{Function}\left[\{x\},C[1]+\frac{1}{2} \left(2 \sqrt{1+4 x}-2 \text{Log}\left[1+\sqrt{1+4 x}\right]\right)\right]\right\}\right\}$$
\end{doublespace}
\end{document}


I would like to have $$instead of \begin{doublespace} \noindent  i.e., as an ordinary \TeX file. - Cross posted here and here – Szabolcs Mar 20 '12 at 6:30 Is it such a big deal to take the LaTeX code saved as shown and then just do a global search-and-replace in a text editor (or, if you prefer, define a Mathematica function to do the same thing upon the saved file? – murray Mar 20 '12 at 18:49 add comment ## 1 Answer The way you do this - by saving the whole notebook with un-formatted In/Out cells - will get you a file with non-traditional working Mathematica notation. For example you will get square brackets for functions instead of round ones and capitalized functions names. If your goal is just to get a nicely formatted formula in TeX form, you could use this (for your 1st equation): In[1]:= f = First[y /. DSolve[y'[x] + x y'[x]^2 == 1, y, x]]; TeXForm[f[x]] Out[1]//TeXForm= c_1+\frac{1}{2} \left(-2 \sqrt{4 x+1}-2 \log \left(1-\sqrt{4 x+1}\right)\right)  If you paste the output in the body of your TeX file between $$ you'll get a nice formula:

If you would like to save the whole document you need to apply some formatting to it, depending on what you exactly need. For example turning an output cell into text cell will result in wrapping the formulas in $$...$$ , which is an equivalent of $...$ in LaTeX.

-