Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Formatting text in Mathematica should be a punishment for serious crimes.

I've face another frustrating feature, and I don't know how to get rid of it.

tekst = StringJoin @@ Array["tekst " &, 15]; 

Composition[
   Grid[{{#, Graphics[Inset@#]}}, Frame -> All] &,  
   Panel[#, ImageSize -> {150, 100}] &,
   Style[#, LineIndent -> 0] &
           ][tekst]

enter image description here

Those texts should look the same imo. The only difference is that the one in Graphics is not formatted as it should be.


Boxes look well and I don't know what causes that:

...
PanelBox[
 StyleBox["\<\"tekst tekst ... tekst \"\>", StripOnInput->False, LineIndent->0],
  ImageSize->{150, 100}], 
GraphicsBox[InsetBox[
PanelBox[
  StyleBox["\<\"tekst ... tekst \"\>", StripOnInput->False, LineIndent->0],
...

I was trying to set FormatType for Insetor BaseStyle for Graphics or ParagraphIndent -> 0. But with no avail :/.

Help me please :P

share|improve this question
    
For me they look the same, but a bit uglier than yours. v8.0.4 linux –  ssch Oct 25 '13 at 13:42
3  
Try adding TextAlignment -> Left to the Style. I think the default for graphics is to centre text. –  Simon Woods Oct 25 '13 at 13:54
    
@SimonWoods I don't know how I've missed that. I suppose I was shocked and in rage of trying all those options on all levels I forgot it somehow :) Thanks –  Kuba Oct 26 '13 at 7:05
    
It's easy to miss I think, because the text is centre aligned within itself, but the text block itself is not centred in the panel. It makes it look like an indent. –  Simon Woods Oct 26 '13 at 8:48
add comment

1 Answer

up vote 3 down vote accepted

Center is the default alignment for text in Graphics, so

Composition[
  Grid[{{#, Graphics[Inset@#]}}, Frame -> All] &, 
  Panel[#, ImageSize -> {150, 100}] &,
  Style[#, LineIndent -> 0, TextAlignment -> Left] &][tekst]

will solve your problem.

tekst.png

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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