Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4366

Re: Getting TraditionalForm to put in a multiplication sign.

From Frank K <fkampas@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Getting TraditionalForm to put in a multiplication sign.
Date 2011-08-13 10:53 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j25l2e$ovr$1@smc.vnet.net> (permalink)
References <j1lomg$nmi$1@smc.vnet.net> <j1r5c4$fi1$1@smc.vnet.net> <j206ud$77n$1@smc.vnet.net>

Show all headers | View raw


On Aug 11, 5:21 am, Simon <simonjty...@gmail.com> wrote:
> Hi Peter,
>
> Using Format is a good idea, but you probably want to combine it with Interpretation so that the output can be reused. In the following I've also restricted the Format to only work on TraditionalForm expressions, but that's not necessary:
>
> In[1]:= Unprotect[Times];
>         Format[HoldPattern[Times[x_, y__]], TraditionalForm] :=
>           Interpretation[Row[{x, y}, "*"], Times[x, y]];
>         Protect[Times];
>
> In[6]:= a f[x] + b g[x + y] + 2 c
>         % // TraditionalForm
>
> Out[6]= 2 c + a f[x] + b g[x + y]
>
> Out[7]//TraditionalForm= a*f(x)+b*g(x+y)+2*c
>
> The problem with Format/Interpretation is that if you try to change an expression to TraditionalForm in place with Ctrl-Shift-T (or the appropriate context/normal menu option), you run into a recursion bug:http://stackoverflow.com/q/4112299/421225
>
> To get around this, maybe it's best to use a manually constructed MakeBoxes rule. For example:
>
> Unprotect[Times];
> Times /: MakeBoxes[HoldPattern[Times[x_, y__]], TraditionalForm] :=
>   With[{row = ToBoxes[Row[{x, y}, "*"], TraditionalForm]},
>    InterpretationBox[row, x y]];
> Protect[Times];
>
> or
>
> Unprotect[Times];
> Times /: MakeBoxes[HoldPattern[Times[x_, y__]], form_] :=
>   With[{row = ToBoxes[Row[{x, y}, "*"], form]},
>    InterpretationBox[row, x y]];
> Protect[Times];
>
> if you want it applying to all formattings.

It's important to remember that what you see on the screen is not
always what you get when you do Export.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Getting TraditionalForm to put in a multiplication sign. Frank K <fkampas@gmail.com> - 2011-08-07 10:16 +0000
  Re: Getting TraditionalForm to put in a multiplication sign. Peter Pein <petsie@dordos.net> - 2011-08-09 11:23 +0000
    Re: Getting TraditionalForm to put in a multiplication sign. Simon <simonjtyler@gmail.com> - 2011-08-11 09:21 +0000
      Re: Getting TraditionalForm to put in a multiplication sign. Frank K <fkampas@gmail.com> - 2011-08-13 10:53 +0000
  Re: Getting TraditionalForm to put in a multiplication sign. Simon <simonjtyler@gmail.com> - 2011-08-10 10:58 +0000

csiph-web