5
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ For me they look the same, but a bit uglier than yours. v8.0.4 linux $\endgroup$
    – ssch
    Oct 25, 2013 at 13:42
  • 3
    $\begingroup$ Try adding TextAlignment -> Left to the Style. I think the default for graphics is to centre text. $\endgroup$ Oct 25, 2013 at 13:54
  • $\begingroup$ @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 $\endgroup$
    – Kuba
    Oct 26, 2013 at 7:05
  • $\begingroup$ 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. $\endgroup$ Oct 26, 2013 at 8:48

1 Answer 1

3
$\begingroup$

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

$\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.