MathGroup Archive 2000

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

Search the Archive

Re: Question to subscript

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22583] Re: Question to subscript
  • From: "David Bailey" <dave-bailey at freeuk.com>
  • Date: Sat, 11 Mar 2000 17:52:53 -0500 (EST)
  • References: <8a52f5$dfm@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

F. Mittermayr <mitterma at linz.vai.co.at> wrote in message
news:8a52f5$dfm at smc.vnet.net...
> Hi,
>
> I want to define a function with 3 parameters f(A_String,index_Integer,
> B_String) and the result should be a string of the form:
>
> A          B
>    index
>
> where only index is subscripted.
>
> In[]=
> f[A_String, index_Integer, B_String]:=ToString[A            ] <> B
>
index
>
> E.g.
> f["A",1,"B"]
>
> but result is that also B is subscripted. How to tell Mathematica B not to
> be subscripted??

You can see what the problem is when you look at the string you get - the
subscript(s) get put in following a newline character. This code gets round
the problem by juxtaposing the variables by multiplying them. The HoldForm
ensures that they do not get swapped round:

f[A_String,index_Integer,B_String]:=ToString[HoldForm[Subscript[A,index]B]]

I wonder why you want strings like this - they are quite ugly (unless you
are using a text only version of Mathematica). Why not use a BoxForm
instead?

David Bailey
Salford Software
db at salford-software.com




  • Prev by Date: new MathSource polyhedra
  • Next by Date: Re: Reduce
  • Previous by thread: Question to subscript
  • Next by thread: magnification issue