I would like to print out an list of reals in a table with perfectly identical number of digits so that they can be perfectly right-aligned. However, once I convert them to strings, TableForm no longer prints them in a column:

  TableForm[RandomReal[1, 20], TableAlignments -> Right]
  TableForm[NumberForm[RandomReal[1, 20], {5, 3}], TableAlignments -> Right]

The first output has an inconsistent number of digits. The second is horizontal. Is there a good workaround for this issue?

NumberForm[#, {5, 3}] & /@ RandomReal[{0, 1}, 20] // TableForm
  • $\begingroup$ Can you explain structure of this? What kind of object does TableForm return and why does NumberForm apply to it? $\endgroup$ – Wynne Mar 20 '18 at 15:56
  • $\begingroup$ ...// TableForm is equivalent to TableForm[...] $\endgroup$ – David G. Stork Mar 20 '18 at 16:50

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.