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.

I like to type in 2d maths into Mathematica and then generate latex code for it. It has been working fine so far until I attempted this expression:

TeXForm[HoldForm[
  S (k*L) = (4*l + 1)/
    2 (Integrate[
      LegendreP[2*l, x]*SphericalBesselJ[0, 1/2*kl*x], {x, -1, 1}])^2/
    Integrate[SphericalBesselJ[0, 1/2*kl*x]^2, {x, -1, 1}]]]

The output latex is

S (k L)=\frac{(4 l+1) \left(\int_{-1}^1 P_{2 l}(x) j_0\left(\frac{\text{kl} x}{2}\right) \,
   dx\right){}^2}{2 \int_{-1}^1 j_0\left(\frac{\text{kl} x}{2}\right){}^2 \, dx}

Which looks like this when compiled.

Mathematica generated code

As you can see there are many style errors (in my opinon). The Integral signs are too small with limits too big, the brackets look weird. The ^2 does not seem in the right place. The problem is if I were to type this out by hand, I come to pretty much the same code as mathematica.

Any help on making this equation beautiful is greatly appreciated.

Thanks

share|improve this question

2 Answers 2

up vote 10 down vote accepted

Here's a solution that uses the directive \displaystyle in both the numerator and the denominator of the fraction. (The align structure is used purely to simplify the before/after comparison.)

enter image description here

\documentclass{article}
\usepackage{amsmath} % for \DeclareMathOperator macro
\DeclareMathOperator{\kl}{kl}   % what does "kl" stand for?
\DeclareMathOperator{\dee}{d\!} % "differential operator"
\begin{document}

\begin{align*}
\text{before:}\quad&
S (k L)=\frac{(4 l+1) \left(\int_{-1}^1 P_{2 l}(x) j_0\left(\frac{\text{kl} x}{2}\right) \,
   dx\right){}^2}{2 \int_{-1}^1 j_0\left(\frac{\text{kl} x}{2}\right){}^2 \, dx}\\
\text{after:}\quad&
S (k L)=\frac{\displaystyle (4 l+1) \biggl(\int_{-1}^1 P_{2 l}(x) j_0\left(\tfrac{1}{2}\kl x\right) \dee x\biggr)^2 }{\displaystyle 2 \int_{-1}^1 j_0\left(\tfrac{1}{2}\kl x\right)^2 \dee x}
\end{align*}
\end{document}
share|improve this answer
    
That is very pleasing to mine eyes. Thanks! –  Steve Hatcher Mar 24 at 7:44

You didn't provide which packages are loaded. I assume minimal and have to change \text with \mathrm.

You can find more information by searching here for large integral sign, such as in Big integral sign

If you take out the {} before the exponents they'll be placed higher. I also assume you're looking for display math.

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{,bigints}
\begin{document}
\[S (k L)=\frac{(4 l+1) \left(\bigintsss_{-1}^1 P_{2 l}(x) j_0\left(\frac{\mathrm{kl} x}{2}\right) \,
   dx\right)^2}{2 \bigintsss_{-1}^1 j_0\left(\frac{\mathrm{kl} x}{2}\right)^2 \, dx}\]
\end{document}
share|improve this answer
2  
Please see the posting Why is \[ ... \] preferable to $$ ... $$? for reasons for not using $$ in LaTeX documents. –  Mico Mar 24 at 6:33
    
Hi, this did improve it a bit, but Mico's code made it phenomenally better. Thanks for your time though. –  Steve Hatcher Mar 24 at 8:13

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.