Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I stretch this Grid to the width of the encapsulating Panel (so that "right" floats on the right side? I want to achieve something along the lines of the menu at the top of the Documentation notebooks.

  {{"left", "nextToLeft", "right"}},
  Alignment -> {{Left, Left, Right}, Baseline}],
 ImageSize -> Full]

Looks like this now:

enter image description here

share|improve this question
up vote 5 down vote accepted

You could use Scaled item sizes but that still requires you to manually get it right:

Panel[Grid[{{"left", "nextToLeft", "right"}}, 
  Alignment -> {{Left, Left, Right}, Baseline}, 
  ItemSize -> {{Scaled[.1], Scaled[.1], Scaled[.8]}}, Frame -> All, 
  Spacings -> {0, 0}], ImageSize -> Full]

So the way I usually do it is to wrap the right hand item in Pane

   {"left", "nextToLeft", 
    Framed@Pane["right", {Full, All}, Alignment -> {Right, Center}, 
      ImageMargins -> 0]}
   }, Alignment -> {{Left, Left, Right}, Baseline}],
 ImageSize -> Full]

I've added a frame so you can see what is happening:

enter image description here

share|improve this answer

You can also use ItemSize -> Fit:

 Panel[Grid[{{"left", "nextToLeft", "right"}}, 
       ItemSize ->Fit,
       Alignment -> {{Left, Left, Right}, Baseline},  
       Frame -> False, Spacings -> {0, 0}], 
    ImageSize -> Full] 

Mixed settings like ItemSize -> {{Scaled[.1], 15, Fit}} also work:

   Panel[Grid[{{"left", "nextToLeft", "right"}}, 
              Alignment -> {{Left, Center, Right}, Baseline}, ItemSize -> #, 
              Frame -> False, Spacings -> {0, 0}], 
        ImageSize ->Full] & /@ 
   {Fit, {{{15, 20, Fit}}}, {{{Fit, 20, Fit}}}, {{{Scaled[.1], 15, Fit}}}}]

enter image description here

Update: Need help locating references in the docs for ItemSize->Fit. I am quite sure I have seen it somewhere in the documentation, but could not find anything using the usual keywords.

The only example I currently have is burried in this great answer by Mike to a different question (thanks Mr.Wizard).

share|improve this answer
Another really useful feature that does not appear to be in the Documentation. (Or is it?) Thanks. – mfvonh May 15 '14 at 15:20
@mfvonh, I am sure I have seen this used somewhere in the docs. But to my surprise I could not find this setting for ItemSize when I searched with keywords Itemsize->Fit, Fit or ItemSize in the docs. – kglr May 15 '14 at 15:43
This works in version 7, where Mike's method unfortunately appears not to. +1 – Mr.Wizard May 15 '14 at 22:09
I note that Mike used Fit himself here: (7499) – Mr.Wizard May 15 '14 at 22:10
@Mr.Wizard, good to know that it is not a Version 9 thing. Amazing you could find Mike's answer using Fit:) I had checked the reference pages for DockedCells but could not find any examples using Fit there. – kglr May 15 '14 at 22:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.