Saturday, 8 June 2013

how to tell latex and pdflatex to wrap a long equation into many lines without editing the tex file?

how to tell latex and pdflatex to wrap a long equation into many lines without editing the tex file?

I asked this at chat first. Then I thought may be I should ask it here.
I use Mathematica to export my notebook as .tex file, then use pdflatex and htlatex to convert them to pdf and html.
Many times the equations are too long to fit in the page width, and the pdf does not show the equation since it does not wrap/break.
Is there a way to add an option to the command line, or some other trick, to tell pdflatex to break this equation into more than one line to fit in the page width?
I do not want to edit the .tex file each time, since it is auto generated, and I can't keep editing it each time I make a change to the Mathematica notebook. So the answers here do not help me in this case since they require one to edit the .tex file.
Here is a small example .tex file generated by Mathematica
%% AMS-LaTeX Created by Wolfram Mathematica 9.0 for Students - Personal Use Only : www.wolfram.com

\documentclass{article}
\usepackage{amsmath, amssymb, graphics, setspace}

\newcommand{\mathsym}[1]

\newcounter{mathematicapage}
\begin{document}

\begin{doublespace}
\noindent\(\pmb{\text{Simplify}[\%]}\)
\end{doublespace}

\begin{doublespace}
\noindent\(x \text{ArcSin}\left[x \sqrt{1-x^2}\right]+\frac{1}{\sqrt{1-x^2+x^4}}\left(1-x^2\right)^{3/2} \left(2+\frac{2}{\left(-1+x^2\right)^2}+\frac{2}{-1+x^2}+\frac{2
(-1)^{5/6} \sqrt{\frac{-1+(-1)^{1/3}+x^2}{-1+x^2}} \sqrt{1-\frac{(-1)^{2/3}}{-1+x^2}} \text{EllipticE}\left[i \text{ArcSinh}\left[\frac{(-1)^{1/3}}{\sqrt{1-x^2}}\right],(-1)^{2/3}\right]}{\sqrt{1-x^2}}-\frac{(-1)^{2/3}
\sqrt{3+\frac{3 (-1)^{1/3}}{-1+x^2}} \sqrt{1-\frac{(-1)^{2/3}}{-1+x^2}} \text{EllipticF}\left[i \text{ArcSinh}\left[\frac{(-1)^{1/3}}{\sqrt{1-x^2}}\right],(-1)^{2/3}\right]}{\sqrt{1-x^2}}\right)\)
\end{doublespace}

\end{document}
Here is the pdf file generated by pdflatex

Notice that, I can create PDF directly from Mathematica. I do set up the page width there to Paperwidth

and the PDF generated by Mathematica does have the wrapping in it done correctly. I just prefer to use pdflatex from the command line since I have makefile that runs and builds everything and I like this part to be automated as well. Here is screen shot from the same notebook, exported to pdf using Mathematica

No comments:

Post a Comment