3
$\begingroup$

I need to show a layer of information on a 3D graphics, inside a manipulate box. Currently, all the code is working great, except that the text should be aligned to the left, while the output numbers should be aligned to the right (with a small spacing between text and the numbers). Here's a MWE to show my problem, and a preview picture :

Info := Text[Row[{ "Initial velocity :\t\t\t\t\t", NumberForm[0.678889, {12, 3}], "\[ScriptC]\n", "Final drift velocity :\t\t\t", NumberForm[0.567892, {12, 3}], "\[ScriptC]\n", "Final velocity :\t", NumberForm[0.5467899, {12, 3}], "\[ScriptC]\n", "Final adiabatic velocity :\t", NumberForm[0.2135467, {12, 3}], "\[ScriptC]\n", "Relative deviation of velocity :\t", NumberForm[112.6732145, {3, 1}], "%\n", "Ratio of radii :\t", NumberForm[237.9867, {3, 1}] }, BaseStyle -> {FontSize -> 14, FontFamily -> "Courier", TextAlignment -> Left}], {0.3, 0.075}] ParametricPlot3D[{Sin[6 t], Cos[12 t], Sin[3 t]}, {t, -10, 10}, PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}, Boxed -> True, Axes -> True, AxesOrigin -> {0, 0, 0}, Epilog -> Info, SphericalRegion -> True, ImageSize -> {700, 700}] 

Preview :

text and numbers

Currently, using several tabs (\t) doesn't work very well.

So how can I align all the text lines to the left, and align all the numbers to the right? (or even align numbers on their point separator, if possible?)

$\endgroup$

1 Answer 1

3
$\begingroup$

You could define Info like this:

Info := Inset[ Grid[{{"Initial velocity : ", NumberForm[0.678889, {12, 3}], "\[ScriptC]"}, {"Final drift velocity : ", NumberForm[0.567892, {12, 3}], "\[ScriptC]"}, {"Final velocity : ", NumberForm[0.5467899, {12, 3}], "\[ScriptC]"}, {"Final adiabatic velocity : ", NumberForm[0.2135467, {12, 3}], "\[ScriptC]"}, {"Relative deviation of velocity : ", NumberForm[112.6732145, {3, 1}], "%"}, {"Ratio of radii : ", NumberForm[237.9867, {3, 1}]}}, BaseStyle -> {FontSize -> 14, FontFamily -> "Courier"}, Alignment -> Left], {0.3, 0.075}] 
$\endgroup$
9
  • $\begingroup$ Appears to work very well. I'll study this... $\endgroup$ Commented Feb 21, 2016 at 17:24
  • $\begingroup$ This solution is doing exactly what I was asking. Thanks a lot ! I'm very tempted to mark it immediately as "THE" solution. Just a question before : what controls the spacing after the numbers, just before their units ? What if I prefer a smaller spacing for the units only ? $\endgroup$ Commented Feb 21, 2016 at 17:34
  • $\begingroup$ See the ItemSize option for Grid. Also using Frame->All to see the grid cells. $\endgroup$ Commented Feb 21, 2016 at 17:45
  • $\begingroup$ Wow ! The Frame->All option is nice, as a table in the 3D view ! $\endgroup$ Commented Feb 21, 2016 at 17:50
  • 1
    $\begingroup$ @NicholasG You can just use Alignment -> {{Left, "."}} $\endgroup$ Commented Mar 24, 2022 at 13:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.