3

Here is one problem I encountered with in Converting Mathematica Notebook to TeX:
https://mathematica.stackexchange.com/questions/25928/save-as-tex-fx-double-s-problem

And I got some double \('s

\(\(f(x)\)\)

Is this a problem of Mathematica? I do not know where else would generate some similar \(s

And, if I cannot control Mathematica to generate single \(, how to change the \(\( to \( conveniently ?

I sometimes use Find/Replace to remove that redundant \( in WinEdt

enter image description here

  • @percusse Is it possible to compile two \(\('s ((f(x)(( without errors, in (for example) WinEdt? – HyperGroups Jun 28 '13 at 12:16
  • 2
    Although it is possible, it is not a good idea. It would be a much better plan to figure out what is causing those double \(s and fix that. It will make your life sooo much easier! – Andrew Stacey Jun 28 '13 at 12:28
  • 6
    I am not on the other site, but in your mathematica set-up it does not make much sense to say that inline should be rendered as DisplayFormula. My guess is the converter used to output $...$ for inline math and $$...$$ for display. Now \(...\) is often to be preferred for inline, but the dispaly equivalent is \[...\] not \(\(...\)\). – Andrew Swann Jun 28 '13 at 12:32
  • @AndrewSwann aha, something similar, good point. Maybe that's the answer. – HyperGroups Jun 28 '13 at 12:51
  • Can you explain that Mathematica code? I have Mathematica on my computer and when I enter in integrals, derivatives, summations, limits, etc. I don't have any issues whereas you are specifying inline, row box, etc. Have you tried just entering in your f[x] := equation without all that and converting to LaTeX? – dustin Jun 28 '13 at 16:23
  • 1
    I feel like this is a Mathematica question rather than a LaTeX one. – Sean Allred Jun 28 '13 at 16:53
  • @dustin there are two methods in Mathematica to convert formula into Tex, one is use to use function TeXForm, another is save notebook as .Tex file. My example is for the second one. – HyperGroups Jun 29 '13 at 07:28

2 Answers2

6

We can change the definition of \( and \) so that they check whether they are followed by another occurrence of themselve and \@gobble that.

These leave the math-shifts $ and $$ as they are, meaning that LaTeX’s superior \[/\] will be used.

Though, it would be better to fix Mathematica’s bug …

Code

\documentclass{article}
\makeatletter
\let\orig@mo\(
\let\orig@mc\)

% (choose one)
% \(\( = display style
\def\({\kernel@ifnextchar\({\expandafter\[\@gobble}\orig@mo}
\def\){\kernel@ifnextchar\){\expandafter\]\@gobble}\orig@mc}

% \(\( = inline math
\def\({\kernel@ifnextchar\({\expandafter\orig@mo\@gobble}\orig@mo}
\def\){\kernel@ifnextchar\){\expandafter\orig@mc\@gobble}\orig@mc}
\makeatother

\begin{document}
inline $ \frac {x^2}{y} $

display $$ \frac {x^2}{y} $$

inline \( \frac {x^2}{y} \)

display \(\( \frac {x^2}{y} \)\)
\end{document}
Qrrbrbirlbel
  • 119,821
4

Almost certainly this is a badly configured conversion wher einline math has changed from $ to \( which has had an accidental effect where $$ has changed to \(\(.

Fixing the convertor would be best but if you go

\let\($  \let\)$

Then \( will act like $ and

aaa\(a=b\)bbbbaaa\(\(c=d\)\)bbbb

will work like

aaa$a=b$bbbbaaa$$c=d$$bbbb

with a=b in inline math annd c=d in display math.

David Carlisle
  • 757,742