MathGroup Archive 2005

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

Search the Archive

Re: CellPrint with text, table and graphics

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57786] Re: [mg57610] CellPrint with text, table and graphics
  • From: Omega Consulting <info at omegaconsultinggroup.com>
  • Date: Wed, 8 Jun 2005 03:21:36 -0400 (EDT)
  • References: <200506020916.FAA11858@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

You're well on your way. All you need are a couple of extra GridBoxes.

If you split the data into a 2 column GridBox (one with the signs, the  
other with the number) then you can align the data after the sign.

If you split the headers from the data, then you can align them  
differently.

The graphic:

gg = Plot[x + 2Sin[x], {x, 0, 2Pi}, Frame -> True,
FrameLabel -> {ToString[Unevaluated[x "-axis"], TraditionalForm],
ToString[Unevaluated[x + y Sin[x]], TraditionalForm]},
TextStyle -> {FontFamily -> "Times", FontSize -> 16},
ImageSize -> 5 72];
gg1 = Cell[GraphicsData["PostScript", DisplayString[gg]]];

The text:

tx = "Some text";
tx1 = StyleBox[tx,
FontFamily -> "Times", FontSize -> 18, FontSlant -> "Italic"];

The table:

FormatData[val_] :=
   {If[val<0, "-", " "], ToBoxes[Abs[val]]}

right=GridBox[Map[FormatData,bb],ColumnSpacings\[Rule]0,ColumnAlignments 
  -> { \
Right,Left}, RowMinHeight\[Rule]1.5];
right//DisplayForm

left = GridBox[Table[{ToBoxes[
       i]},{i,0,Length[bb]-1}], RowMinHeight\[Rule]1.5];
left//DisplayForm

outer = GridBox[{{FormBox["k", TraditionalForm],
FormBox[SubscriptBox["b", "k"], TraditionalForm]},
         {left, right}},  
ColumnAlignments\[Rule]Center,ColumnSpacings\[Rule]3];
outer//DisplayForm

Put it together:
CellPrint[
Cell[ BoxData[ GridBox[{{gg1, GridBox[{{tx1}, {outer}},
RowsEqual -> False, RowLines -> True, RowSpacings -> 5]}},
RowAlignments -> Center, ColumnLines -> True, GridFrame -> True] ],
"Text"]]

----------------------------------------------
Omega Consulting
The final answer to your Mathematica needs.
http://omegaconsultinggroup.com

On Jun 2, 2005, at 4:16 AM, Hugh Goyder wrote:

> I am trying to work out how to mix text, a table and graphics all in  
> one
> cell. Developing a previous post (which I can't now find) I have got  
> as far
> as the code below.
>
> 1. Can my approach be improved on and made simpler?
>
> 2. Can the data in the table be aligned on the first digit so that the
> negative sign projects to the left? I note that sign counts as one  
> digit it
> would be better if it didn't.
>
> 3. Can the heading for the column in the table, bk,  be centered over  
> the
> column? (The heading should be in Traditional form and be b subscript  
> k but
> this caused a flood of box forms to appear when I cut and pasted the  
> email)
>
>
>
> Thanks
>
> Hugh Goyder
>
> (* generate raw text, data and graphics *)
> tx = "Some text";
> bb = {-19214.88484, 230.1609318, -1.028803876, 0.002414336487,
> -2.902395566 10^(-6), 1.430493449 10^(-9)};
> tt = Transpose[{Table[n - 1, {n, Length[bb]}], bb}];
> gg = Plot[x + 2Sin[x], {x, 0, 2Pi}, Frame -> True,
> FrameLabel -> {ToString[Unevaluated[x "-axis"], TraditionalForm],
> ToString[Unevaluated[x + y Sin[x]], TraditionalForm]},
> TextStyle -> {FontFamily -> "Times", FontSize -> 16},
> ImageSize -> 5 72];
>
>
> (* format text, data and graphics *)
> tx1 = StyleForm[tx,
> FontFamily -> "Times", FontSize -> 18, FontSlant -> "Italic"]
> tt1 = TableForm[tt, TableHeadings -> {None,
> {ToString[Unevaluated[k], TraditionalForm],
> ToString[Unevaluated[bk], TraditionalForm]}},
> TableAlignments -> {Left}]
> gg1 = Cell[GraphicsData["PostScript", DisplayString[gg]]];
>
>
> (* print a cell with mixed text, data and graphics *)
> CellPrint[
> Cell[ BoxData[ GridBox[{{gg1, GridBox[{{ToBoxes[tx1]}, {ToBoxes[tt1]}},
> RowsEqual -> False, RowLines -> True, RowSpacings -> 5]}},
> RowAlignments -> Center, ColumnLines -> True, GridFrame -> True] ],
> "Text"]]
>
>


  • Prev by Date: Re: Function Fit to 3D data set
  • Next by Date: string to a special list
  • Previous by thread: CellPrint with text, table and graphics
  • Next by thread: Re: How To Override FrontEnd/init.m Settings?