Message Boards Message Boards

3
|
970 Views
|
0 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Formatting Column[] and Row[] like Grid[]

Posted 4 years ago

I am still new to Wolfram and Mathematica, but I am already loving the great variety of ways to tell a story with both simple and complex visualizations using Mathematica. But, I got a bit frustrated with the differences between how Column[] and Row[]. I really wanted all of the same options that I get with Grid[].

As an example, I really wanted to be able to align elements of a row with at the top (instead of the center).

After not finding an answer anywhere, I realized that a Row[] is just a single row Grid[] and a Column[] is just a single column Grid[]. So, to get all of the options of Grid[], I should just use Grid[] and give up on Row[] and Column[].

Of course, that could lead to some code that is less than pleasant to read, so I wrote me some helper functions:

Options[tdyRow] = Options[Grid];
tdyRow[items_List, opt : OptionsPattern[]] := Grid[{items}, opt];
tdyRow[item_, opt : OptionsPattern[]] := tdyRow[{item}, opt];


Options[tdyColumn] = Options[Grid];
tdyColumn[items_List, opt : OptionsPattern[]] := 
  Grid[Map[{#} &, items], opt];
tdyColumn[item_, opt : OptionsPattern[]] := tdyColumn[{item}, opt];

Since I'm still new to Wolfram and Mathematica, I'm posting this in hopes that:

  • This idea might help others
  • Others might teach me a better way

Thanks, and stay safe and well.

POSTED BY: Mike Besso
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract