I am using WriteString to avoid automatic line change. But it seems like the it does not work with Style, like the following

a = 7;
Style[WriteString["stdout", a], FontSize -> 47]

The FontSize seems to be not effective. Does WriteString not work with Style at all? If so, how can I even change the font size of a WriteString output?

It seems like my language is not very clear, so the reason why I ask this question is, I would like to print all possible arrangement of the some letters, say I define a function

f[i_] := Which[i == 1, "A", i == 2, "B", i == 3, "C"]

and Mathematica is expected to print

  • 1
    $\begingroup$ WriteString is designed for writing to streams, such as files. In what sense are you wanting to add a style in such a situation? What file format are you dealing with? And if you AREN’T trying to write to a file, then I think you want a different function than WriteString. $\endgroup$ – Kevin Ausman May 16 at 23:33
  • 1
    $\begingroup$ As a follow up, stdout only accepts text, not styles. This is described in the documentation: reference.wolfram.com/language/tutorial/… $\endgroup$ – Kevin Ausman May 16 at 23:35
  • $\begingroup$ What do you mean by "automatic line change"? $\endgroup$ – m_goldberg May 17 at 0:26
  • 1
    $\begingroup$ Paste[Style["Thing to display", 24]] $\endgroup$ – Kevin Ausman May 17 at 18:34
  • 1
    $\begingroup$ Instead of adding material to the answer below, add it to your question or submit a new answer of your own. $\endgroup$ – bbgodfrey May 19 at 3:25

I think there still deficiencies in my understanding of what the OP wants because of:

  • language difficulties
  • the OP's example does not involve "several outputs" as mentioned in comments

Despite this I will give the question a shot.

Mathematica has a number of output wrapping forms that will group multiple objects on one line. I think in your case Row might be the form you are looking for.

Using Row along with Style allows multiple objects of almost any kind, not just strings, to be placed and formatted on one line. You can wrap Row in a master style and override the master style for any of the individual objects.

For example

p = 1; q = 2;
    {Subscript["t", Style[p, Plain]] + Subscript[t, Style[q, Plain]], 
     Style["→", Red], "F≡I"}],
  Bold, FontFamily -> "Times", 36]



If you must print your permutations, a more typical Mathematica style would be:

    Print @ Style[Row[perm], FontFamily->"Times", 46],
    {perm, Permutations[{"A", "B", "C"}]}

During evaluation of In[434]:= ABC

During evaluation of In[434]:= ACB

During evaluation of In[434]:= BAC

During evaluation of In[434]:= BCA

During evaluation of In[434]:= CAB

During evaluation of In[434]:= CBA

If you actually want to do something afterwards with the permutation, something like:

    Style[Row[perm], FontFamily->"Times",46],


might be more useful.


Thanks to m_goldberg's answer, I was able to figure out a solution based on his or her post

letter[i_] := Which[i == 1, "A", i == 2, "B", i == 3, "C"]

For[i = 1, i <= 3!, i++, 
   Row[{Style[letter[Permutations[{1, 2, 3}][[i]][[1]]], Plain], 
     Style[letter[Permutations[{1, 2, 3}][[i]][[2]]], Plain], 
     Style[letter[Permutations[{1, 2, 3}][[i]][[3]]], Plain]}], 
   FontFamily -> "Times", 46]]]

which will print all arrangement of letters A, B and C.


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.