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


Groups > comp.soft-sys.math.mathematica > #5964 > unrolled thread

Strings with different Styles in a Grid

Started byDon <donabc@comcast.net>
First post2011-10-28 09:42 +0000
Last post2011-10-29 11:28 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Strings with different Styles in a Grid Don <donabc@comcast.net> - 2011-10-28 09:42 +0000
    Re: Strings with different Styles in a Grid A Retey <awnl@gmx-topmail.de> - 2011-10-29 11:10 +0000
    Re: Strings with different Styles in a Grid "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-10-29 11:28 +0000

#5964 — Strings with different Styles in a Grid

FromDon <donabc@comcast.net>
Date2011-10-28 09:42 +0000
SubjectStrings with different Styles in a Grid
Message-ID<j8dteq$kfm$1@smc.vnet.net>
Here is a Grid of strings, with some strings having different styles.

Grid[{{Style["aa", Red, Bold], Style["bb", Green]}, {"cc", "dd"}}]

The "cc" string should be output with the first "c" in the color Blue and 
in Bold, the second "c" should be in the color Red.

How does one "break apart" the "cc" string to give each "c" a different style
while still maintaining it as a single item for the Grid function?

Something like this, which is very intuitive, simply doesn't work

Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
  {{Style["c", Blue, Bold], Style["c", Red]}, "dd"}}]


And this, doesn't work either  ... 

Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
  {StringJoin[Style["c", Blue, Bold], Style["c", Red]], "dd"}}]

Thank you in advance.

Don

[toc] | [next] | [standalone]


#5975

FromA Retey <awnl@gmx-topmail.de>
Date2011-10-29 11:10 +0000
Message-ID<j8gmvs$56b$1@smc.vnet.net>
In reply to#5964
Am 28.10.2011 11:42, schrieb Don:
> Here is a Grid of strings, with some strings having different styles.
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]}, {"cc", "dd"}}]
>
> The "cc" string should be output with the first "c" in the color Blue and
> in Bold, the second "c" should be in the color Red.
>
> How does one "break apart" the "cc" string to give each "c" a different style
> while still maintaining it as a single item for the Grid function?
>
> Something like this, which is very intuitive, simply doesn't work
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
>    {{Style["c", Blue, Bold], Style["c", Red]}, "dd"}}]
>
>
> And this, doesn't work either  ...
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
>    {StringJoin[Style["c", Blue, Bold], Style["c", Red]], "dd"}}]
>
> Thank you in advance.
>
> Don

you were just missing an additional Row, as here:

Grid[{{Style["aa", Red, Bold],
    Style["bb",
     Green]}, {Row[{Style["c", Blue, Bold], Style["c", Red]}], "dd"}}]

alternatively you could use another Grid, which needs a little more 
typing but gives you somewhat more control about the exact appearance 
and solves possible issues with line breaks (you might find notes from 
John Fultz about the difference between Row and Grid in earlier posts to 
this group):

Grid[{{Style["aa", Red, Bold],
    Style["bb",
     Green]}, {Grid[{{Style["c", Blue, Bold], Style["c", Red]}},
     Spacings -> 0], "dd"}}]

hth,

albert

[toc] | [prev] | [next] | [standalone]


#6014

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2011-10-29 11:28 +0000
Message-ID<j8go0g$5iq$1@smc.vnet.net>
In reply to#5964
On Fri, 28 Oct 2011 10:42:50 +0100, Don <donabc@comcast.net> wrote:

> Here is a Grid of strings, with some strings having different styles.
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]}, {"cc", "dd"}}]
>
> The "cc" string should be output with the first "c" in the color Blue and
> in Bold, the second "c" should be in the color Red.
>
> How does one "break apart" the "cc" string to give each "c" a different  
> style
> while still maintaining it as a single item for the Grid function?
>
> Something like this, which is very intuitive, simply doesn't work
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
>   {{Style["c", Blue, Bold], Style["c", Red]}, "dd"}}]
>
>
> And this, doesn't work either  ...
>
> Grid[{{Style["aa", Red, Bold], Style["bb", Green]},
>   {StringJoin[Style["c", Blue, Bold], Style["c", Red]], "dd"}}]
>
> Thank you in advance.
>
> Don
>

Try:

Grid[{
  {Style["aa", Red, Bold], Style["bb", Green]},
  {Row[{Style["c", Blue, Bold], Style["c", Red]}], "dd"}
}]

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web