Re: Displaying a table
- To: mathgroup at smc.vnet.net
- Subject: [mg110119] Re: Displaying a table
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 2 Jun 2010 02:06:57 -0400 (EDT)
subx = {0, 0, 0, 0, 0, 0};(*this is an example*)lenx = Length[subx]; circorr = Table[0, {lenx}, {lenx}]; circorr[[2, 5]] = 6; circorr[[3, 4]] = 8; Grid[ Map[ Style[#, If[# > 0, Bold, Plain]] &, circorr, {2}], Spacings -> 2] TableForm[ Map[ Style[#, If[# > 0, Bold, Plain]] &, circorr, {2}], TableSpacing -> {1.25, 2.75}] Bob Hanlon ---- "S. B. Gray" <stevebg at ROADRUNNER.COM> wrote: ============= I need to display the subx table as shown, with no decimal points or {} and with some spaces between columns. Some entries will be nonzero and it would be nice to show them in boldface. I tried Style with Positive but didn't succeed. This method works but there must be a better way. subx = {0, 0, 0, 0, 0, 0}; (* this is an example *) lenx = Length[subx]; circorr = Table[0, {lenx}, {lenx}]; circorr[[2, 5]] = 6; circorr[[3, 4]] = 8; (* Only examples. *) ts1 = ToString[circorr]; ts1 = StringReplace[ts1, ", " -> " "]; ts1 = StringReplace[ts1, "{" -> ""]; ts1 = StringReplace[ts1, "}" -> "\r"]; (* To print >0 in Bold? *) Print[" ", TableForm[ts1]] (* which gives this: *) 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Thanks to everyone for past and present help. Steve Gray