MathGroup Archive 2007

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

Search the Archive

Fwd: correction to: more than 1.5 hrs of trying: Grid Alignment problem ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80830] Fwd: correction to: more than 1.5 hrs of trying: Grid Alignment problem ?
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Tue, 4 Sep 2007 03:34:02 -0400 (EDT)
  • References: <acbec1a40708310407t5743b5d6m1e2963988ddeaab8@mail.gmail.com>

I have tested so many examples that I sent in the wrong ones:

The two examples (which still don't work) should (probably) have been:
tab={{1,1,1,1000},{2,2,2000,2},{3,3000,3,3},{4000,4,4,4}}
Grid[tab,Alignment->{Baseline,{Center,Center,{Right}}}]
Grid[tab,Alignment->{Automatic,{{Right},1->Center,2->Center}}]


On 8/31/07, Chris Chiasson <chris at chiasson.name> wrote:
> tab={{1,1,1,1000},{2,2,2000,2},{3,3000,3,3},{4000,4,4,4}}
>
> Grid[tab, Alignment -> {{Center, Center, Right}, Baseline}]
>
> The above command does not work to center the horizontal alignment of
> the **first two** grid rows, while right aligning the rest, which is
> what I want to do.
>
>
> The pattern-based structure (as opposed to the optional rule-based
> one) of the Alignment option is not very clear to me. The only
> detailed description of pattern based Grid option syntax is given for
> Background in
>
> tutorial/GridsRowsAndColumns
>
> . Alignment is a little more complicated because each cell has a
> top/bottm & left/right alignment instead of a (single Background)
> color, but I can't find a detailed description of its syntax.
>
>
> I haven't even been able to make it work using the rule based syntax:
>
> Grid[tab,
>  Alignment -> {{{Right}, 1 -> Center, 2 -> Center}, Automatic}]
>
> The behavior is quite interesting, because the rest of the rows take
> on the behavior of 1 and 2, even though (I think) I never gave that
> instruction.
>
>
> Is something wrong with Alignment? Can anyone make the pattern based
> syntax work? Failing that, what about the rule based syntax?
>
>
> I am even desperate enough to code up a random alignment option test.
> Mathematica has a nasty habit of crashing (which I do not think is my
> fault) during the test, but none of the random alignments I have
> tested do what I want either. Perhaps the code will be useful to
> others for finding problems with Mathematica:
>
> nestRandom[f_, randomIntegerArg_, head_[args__], 1] :=
>   f @@ Table[
>     RandomChoice[
>      Unevaluated@{args}], {RandomInteger@randomIntegerArg}];
> nestRandom[f_, randomIntegerArg_, head_[args__],
>   maxIterations : _Integer : 10] :=
>  With[{newMaxIterations = maxIterations - 1},
>   f @@ Table[
>     Function[Null, RandomChoice@Unevaluated@{##}, HoldAllComplete] @@
>      Append[HoldComplete[args],
>       Unevaluated@
>        f@nestRandom[f, randomIntegerArg, head[args],
>          newMaxIterations]], {RandomInteger@randomIntegerArg}]]
> tab = {{1, 1, 1, 1000}, {2, 2, 2000, 2}, {3, 3000, 3, 3}, {4000, 4, 4,
>     4}}
> Table[CellPrint[
>    ExpressionCell[
>     With[{alignment =
>        nestRandom[List, {0, 4}, {Center, Right, Automatic, Baseline},
>         3]}, {i, Grid[tab, Alignment -> alignment], alignment}],
>     "Item1Numbered"]], {i, 1000}];
>
>
>
>
>
>
>
> --
> http://chris.chiasson.name/
>


--
http://chris.chiasson.name/


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: is there a better way to do constraint logic
  • Next by Date: Re: date format
  • Previous by thread: Re: StringCases kills Kernel
  • Next by thread: Re: Fwd: correction to: more than 1.5 hrs of trying: Grid Alignment problem ?