1
$\begingroup$

Use of a vertical Spacer in justified text inside a graphic isn't working as required. The result in the green box looks right, but when this is placed in a graphic the spacing is messed up. Is there some way to fix it?

g1 = StringTake[ExampleData[{"Text", "BeowulfModern"}], {4740, 5200}];
g2 = StringTake[g1, 319] <> "\n";
g3 = StringDrop[g1, 319];
g4 = Row[{g2, Spacer[{0, 30}], g3}];

TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1, 
 Background -> LightGreen]

Graphics[{
  LightBlue, Rectangle[{0, 0}, {500, 140}], Black,
  Inset[TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1],
   {0, 0}, {Left, Bottom}, {500, Automatic}]},
 PlotRange -> {{0, 500}, {0, 140}}, ImageSize -> 500,
 BaseStyle -> {FontFamily -> "Courier New", FontSize -> 12}]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ It works fine in version 9. I don't have a 7 so can not test it. A wild guess is something goes wrong with the baseline alignment.. Maybe try Column instead of Row in g4? $\endgroup$
    – Silvia
    Jan 17, 2013 at 18:01
  • $\begingroup$ Chris, I found this question deleted but I can duplicate both the problem and the solution so I undeleted it. If this is a problem I can delete it again but I am assuming you thought it was of no interest, yet it is. $\endgroup$
    – Mr.Wizard
    Jan 21, 2013 at 18:30
  • $\begingroup$ @Mr.Wizard - I thought I was going to need the Magnify trick again, but an option sufficed. mathematica.stackexchange.com/a/15766/363 $\endgroup$ Jan 22, 2013 at 7:30

1 Answer 1

2
$\begingroup$

Problem fixed with the TextCell option CellBaseline, i.e.:-

Graphics[{LightBlue, Rectangle[{0, 0}, {500, 140}], Black,
  Inset[TextCell[g4, LineSpacing -> {0, 16}, TextJustification -> 1,
    CellBaseline -> Bottom],
   {0, 0}, {Left, Bottom}, {500, Automatic}]},
 PlotRange -> {{0, 500}, {0, 140}}, ImageSize -> 500,
 BaseStyle -> {FontFamily -> "Courier New", FontSize -> 12}]

By the way, this method is handy to give a line separation less than "\n" would provide.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.