MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Format and TeXForm question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66828] Format and TeXForm question
  • From: Steve White <swhite at jsu.edu>
  • Date: Wed, 31 May 2006 06:31:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Steve White
Department of Mathematics
Jacksonville State University
swhite at jsu.edu

I have two questions which are related.

*********************************************************************
First Question
*********************************************************************

In Mathematica versions 3 to 4 (and I believe 5)

I get the following:



In[1]:= Format[par[a_], TeXForm] := 
StringJoin["\\left(",ToString[TeXForm[HoldForm[a]]], "\\right)"];


In[2]:=TeXForm[a*par[b + c]]
Out[2]//TeXForm= a\,\left(b + c\right)


Which is exactly what I would expect to happen.



However in Mathematica 5.2 I get the following:



In[3]:= Format[par[a_], TeXForm] :=
    StringJoin["\\left(", ToString[TeXForm[HoldForm[a]]], "\\right)"];


In[4]:=TeXForm[a*par[b + c]]
Out[4]//TeXForm= a \text{par}(b+c)


How do I get the TeXForm output of my function par
to work as it did in Mathematica 4.



**********************************************************************
Second Question
**********************************************************************

My second question is related to the first. Namely how is
Mathematica 5.2 now handing the Format command for TeXForm verses
how it used to in version 4.



In the Mathematica 4 and 5 book the following example is given
as an illustration of the Format statement.


In[5]:=  Format[x, TeXForm] := "{\\bf x}";
In[6]:=   TeXForm[1 + x^2]
Out[6]//TeXForm= 1 + {{\bf x}}^2

This is what one would expect.




However in the online documentation for Mathematica, the above
example is given as



In[7]:=  Format[x, TeXForm] := "{\\bf x}";
In[8]:=   TeXForm[1 + x^2]
Out[8]//TeXForm= x^2+1



So the example in the documentation makes it appear that nothing
has happened.


When I execute these same commands in Mathematica 5.2 this is,
in fact, what happens.




In Mathematica 5.2 I get the following:

In[8]:= Format[x, TeXForm] := "{\\bf x}";
In[9]:=TeXForm[x]
Out[9]//TeXForm=\text{$\{\backslash \backslash $bf x$\}$}







In Mathematica 5.2 I also get the following


In[10]:=TeXForm["{\\bf x}"]
Out[10]//TeXForm=\text{$\{\backslash \backslash $bf x$\}$}



So it appears that when the commands

In[11]:= Format[x, TeXForm] := "{\\bf x}";
In[12]:=TeXForm[x]

are executed

Mathematica 5.2 is converting x to "{\\bf x}" and
then is again converting "{\\bf x}" to
\text{$\{\backslash \backslash $bf x$\}$}.

Can someone explain what is happening here?
I have contacted Wolfram's technical support several times, with
no success whatsoever. I have dozens of special TeXForm changes that
I need to implement all of which worked as expected in Mathematica 3 and
4.












--Alt-Boundary-1097.17300359
Content-type: text/html; charset=US-ASCII
Content-description: Mail message body

<?xml  version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">Steve White</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Department of Mathematics</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Jacksonville State University</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">swhite at jsu.edu</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I have two questions which are related.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">*********************************************************************</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">First Question</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">*********************************************************************</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In Mathematica versions 3 to 4 (and I believe 5)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I get the following:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[1]:= Format[par[a_], TeXForm] := 
StringJoin[&quot;\\left(&quot;,ToString[TeXForm[HoldForm[a]]], &quot;\\right)&quot;];</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[2]:=TeXForm[a*par[b + c]]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[2]//TeXForm= a\,\left(b + c\right)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Which is exactly what I would expect to happen.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">However in Mathematica 5.2 I get the following:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[3]:= Format[par[a_], TeXForm] :=</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&#160;&#160;&#160; StringJoin[&quot;\\left(&quot;, ToString[TeXForm[HoldForm[a]]], &quot;\\right)&quot;];</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[4]:=TeXForm[a*par[b + c]]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[4]//TeXForm= a \text{par}(b+c)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">How do I get the TeXForm output of my function par</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">to work as it did in Mathematica 4.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">**********************************************************************</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Second Question</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">**********************************************************************</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">My second question is related to the first. Namely how is</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Mathematica 5.2 now handing the Format command for TeXForm verses</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">how it used to in version 4.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In the Mathematica 4 and 5 book the following example is given</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">as an illustration of the Format statement.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[5]:=&#160; Format[x, TeXForm] := &quot;{\\bf x}&quot;;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[6]:=&#160;&#160; TeXForm[1 + x^2]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[6]//TeXForm= 1 + {{\bf x}}^2</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">This is what one would expect.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">However in the online documentation for Mathematica, the above</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">example is given as</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[7]:=&#160; Format[x, TeXForm] := &quot;{\\bf x}&quot;;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[8]:=&#160;&#160; TeXForm[1 + x^2]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[8]//TeXForm= x^2+1</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">So the example in the documentation makes it appear that nothing</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">has happened.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">When I execute these same commands in Mathematica 5.2 this is,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">in fact, what happens.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In Mathematica 5.2 I get the following:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[8]:= Format[x, TeXForm] := &quot;{\\bf x}&quot;;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[9]:=TeXForm[x]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[9]//TeXForm=\text{$\{\backslash \backslash $bf x$\}$}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In Mathematica 5.2 I also get the following</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[10]:=TeXForm[&quot;{\\bf x}&quot;]</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Out[10]//TeXForm=\text{$\{\backslash \backslash $bf x$\}$}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">So it appears that when the commands</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[11]:= Format[x, TeXForm] := &quot;{\\bf x}&quot;;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">In[12]:=TeXForm[x]</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">are executed</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Mathematica 5.2 is converting x to &quot;{\\bf x}&quot; and</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">then is again converting &quot;{\\bf x}&quot; to</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">\text{$\{\backslash \backslash $bf x$\}$}.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Can someone explain what is happening here?</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I have contacted Wolfram's technical support several times, with</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">no success whatsoever. I have dozens of special TeXForm changes that</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I need to implement all of which worked as expected in Mathematica 3 and</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">4.</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"></div>
</body>
</html>

--Alt-Boundary-1097.17300359--


  • Prev by Date: Finding poles, branch cuts and other complex singularities
  • Previous by thread: Finding poles, branch cuts and other complex singularities