0
$\begingroup$

This following table works nicely --- sorry for the french

l = {"A", "B", "C", "D", "E"}
per = Permutations[l];
info = Table[
   StringJoin[Riffle[per[[i]], {"\[Succeeds]"}]], {i, 1, Length[per]}];
propd = Table[info[[i]], {i, 1, Length[per]/6}, {j, 1, 6}];
enterdata = 
  Table[With[{i = i, j = j}, 
    InputField[Dynamic[propd[[i, j]]], FieldSize -> 11, 
     Background -> LightGray]], {i, 1, Length[per]/6}, {j, 1, 6}];
{{Style["Substituer le nombre d'agents qui ont les préférences \
indiquées.", Red]}, {Style[
    "(Ce nombre est automatiquement substitué et il n'est pas \
nécessaire de compiler la commande."]},
  {Style["Le nom du vecteur ainsi construit est propd)"]}, \
{enterdata}} // TableForm

I dont Know how

1) to center the text

2) to add a command which centers the table in the notebook

3) that the modification be on the variable propd after to have been Flatten

$\endgroup$
1
$\begingroup$

You need to add option Alignment -> Center to the InputFields to center the text in them, and for the table itself I recommend using Grid also with Alignment -> Center. I'm not really sure what you mean by 3) but if you are asking how to get the changes to propd, the InputField dynamically updates the value of propd. My modifications to your code look like this:

l = {"A", "B", "C", "D", "E"}
per = Permutations[l];
info = Table[
   StringJoin[Riffle[per[[i]], {"\[Succeeds]"}]], {i, 1, Length[per]}];
propd = Table[info[[i]], {i, 1, Length[per]/6}, {j, 1, 6}];
enterdata = Table[
   With[
    {i = i, j = j},
    InputField[Dynamic[propd[[i, j]]], FieldSize -> 11, 
     Background -> LightGray, Alignment -> Center]
    ],
   {i, 1, Length[per]/6},
   {j, 1, 6}
   ];
Grid[
 Join[
  {
   {Style[
     "Substituer le nombre d'agents qui ont les préférences \
indiquées.", Red], SpanFromLeft, SpanFromLeft, SpanFromLeft, 
    SpanFromLeft, SpanFromLeft},
   {Style[
     "(Ce nombre est automatiquement substitué et il n'est pas \
nécessaire de compiler la commande."], SpanFromLeft, SpanFromLeft, 
    SpanFromLeft, SpanFromLeft},
   {Style["Le nom du vecteur ainsi construit est propd)"], 
    SpanFromLeft, SpanFromLeft, SpanFromLeft, SpanFromLeft}
   },
  enterdata
  ],
 Alignment -> Center
 ]
$\endgroup$
  • $\begingroup$ Thanks lowriniak. In what concerns 3), I need a vector not a matrix so the lines must be concatenated in one unique. $\endgroup$ – cyrille.piatecki Nov 18 '16 at 14:54
  • $\begingroup$ For that you could make a new variable propdCat := Flatten[propd] (you can flatten to whatever level is needed. Alternatively you could have a button that changes propd to whatever shape you need (note that this will then break your input grid). The button code would be something like Button[ "Flatten propd", propd = Flatten[propd]] $\endgroup$ – lowriniak Nov 18 '16 at 15:00
  • $\begingroup$ Good Idea! Thanks $\endgroup$ – cyrille.piatecki Nov 18 '16 at 15:43

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.