1
$\begingroup$

I want to make a list of functions like this:

functionList = 
  {{Style["Function", Larger, Bold], Style["Notes", Larger, Bold], 
 Style["Source", Larger, Bold]}, 
  {"f[n]=a", "Long long long long description - I'd like it to wrap within the cell", "Wikipedia"}, 
  {"g[n]=b", "I'd like to be able to select this function and copy-and-paste", 
 "Wikipedia"}, 
  {"\[VerticalEllipsis]", "\[VerticalEllipsis]", "\[VerticalEllipsis]"}}; 

Grid[functionList, Alignment -> {Left, Top}, Spacings -> {2, 2}, Frame -> All]

enter image description here

I have two questions:

  1. I need a way of setting the cell-widths, and then instructing text to wrap within that width. Is this possible? I don't think this answer is quite what I'm after - at least, I can't see how to apply it.
  2. I'd like to be able to select a function from the outputted Grid and copy it so I can paste it elsewhere. Is there a way to do this, without actually forcing Mathematica to evaluate the expression? I could write f[n]==a instead of "f[n]=a", for example, and it would appear in copy-and-pastable form; but then Mathematica would evaluate it, which I want to avoid.

Thanks in advance for your suggestions.

$\endgroup$
0
$\begingroup$

You can use TextGrid with the ItemSize option:

TextGrid[
 functionList,
 Alignment -> {Left, Top},
 Spacings -> {2, 2},
 Frame -> All,
 ItemSize -> {{5, 30, 10}, Automatic}
 ]

You could also use the ItemSize option with Grid, but TextGrid looks a bit better, and also it takes care of the copy-and-paste problem that you encountered.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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