2
$\begingroup$

I can't align colum data on the decimal point:

data = { {1, 45000.5, 27500.}, {2, 22500., 18333.3},
         {3, 15000., 13750.}, {4, 11250., 11000.},
         {5, 9000., 9166.67} }

Grid[data, {Alignment->".", Frame-> All}]

Here is a screen capture of the result as seen in the Notebook:

enter image description here

I tried many syntax variations for the Alignment option. And I also tried TextGrid instead of a plain Grid and TableForm alongside TableAlignements. I never obtained a table whose values are aligned on the decimal point.

TableForm[data, TableAlignments->"."]
Grid[data, {Alignment->".", Frame-> All}]
Grid[data, {Alignment->{".","."}, Frame-> All}]
Grid[data, {Alignment->{{".","."}}, Frame-> All}]

I saw a seven-years-old question that states there is an issue with alignment to the decimal point. But as far as I understood it, this is only triggered when using ItemSize. Not when using Alignment only.

Explicitly using a NumberForm and Right aligning the data is kind of a workaround, but this is not entirely satisfying.

Any thoughts or suggestions to fix my issue?


It appears the issue is with the Notebook: when I export the result as an image, data are properly aligned:

enter image description here

How to ensure the table is properly displayed in the Notebook too?

FWIW, I'm using Wolfram Cloud in a Firefox 69.02 browser on Linux

$\endgroup$
3
  • $\begingroup$ Sylvain, I can't reproduce your problem in the desktop version of MMA (v12, Win10-64), so the problem seems to be with the cloud version only. $\endgroup$
    – MarcoB
    Dec 9, 2019 at 18:36
  • $\begingroup$ Thanks @Marco. Indeed it seems related to the Cloud Notebook and/or my Browser. I've added the relevant tag to the question. FWIW, exporting the table either as bitmap or PDF will display the data with proper alignment. $\endgroup$ Dec 9, 2019 at 18:39
  • 2
    $\begingroup$ Grid alignment at characters is not supported in cloud notebooks yet, but coming soon (maybe Cloud 1.55 in 2020 Q1). $\endgroup$ Dec 13, 2019 at 9:53

1 Answer 1

1
$\begingroup$

As a workaround, wrapping the grid inside a Rasterize function displays the table with proper formatting--at the expanse of making the result uneditable:

Rasterize[Grid[data, {Alignment->".", Frame-> All}]]

text vs. rasterized version of output

$\endgroup$
2
  • 1
    $\begingroup$ Yes, that would be an OK workaround for now. Just FYI, you can also convert a cell to an image using the cell gear menu (next to the cell bracket in cloud notebooks): Convert to > Image. You can also use the cell option CloudRenderingMethod->"Bitmap" to force rendering as a bitmap. $\endgroup$ Dec 13, 2019 at 9:50
  • $\begingroup$ Thanks for the info @Jan. $\endgroup$ Dec 13, 2019 at 13:05

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.