3
$\begingroup$

I though this should be a simple one, but I have run into issues. I have a style for Graphics, which holds things like plots generated as outputs from commands, as well as images I may have inserted into a notebook via Insert->Picture->From file..., say. The issue is that I would like those graphics to be centered relative to other cells, such as my text cells. However, the graphics come out centered on the page, which is off since my text cells are indented. Here are the style definitions I am using:

This is Text, for example:

Cell[StyleData["Text"],
 CellMargins->{{66, 10}, {7, 7}},
 StyleKeyMapping->{
  "Backspace" -> "Subsubsubsubsection", "Tab" -> "SmallText", 
   KeyEvent["Tab", Modifiers -> {Shift}] -> "Input"},
 CellChangeTimes->{3.61081924778518*^9},
 TextAlignment->Left,
 TextJustification->1.,
 MenuSortingValue->9,
 MenuCommandKey->"4",
 FontFamily->"Source Serif Pro",
 FontSize->12,
 FontWeight->"Plain",
 FontSlant->"Plain",
 FontVariations->{"StrikeThrough"->False,
 "Underline"->False},
 FontProperties->{"ScreenResolution"->Automatic}]

Here is my Graphics style:

Cell[StyleData["Graphics"],
 CellFrame->False,
 TextAlignment->Center,
 TextJustification->0.,
 MenuSortingValue->10000,
 FontFamily->"Source Serif Pro",
 FontSize->12,
 FontWeight->"Plain",
 FontSlant->"Plain",
 FontVariations->{"StrikeThrough"->False,
 "Underline"->False},
 FontProperties->{"ScreenResolution"->Automatic},
 Background->None,
 GraphicsBoxOptions->{ImageSize->600}]

I tried simply inserting the line

 CellMargins->{{66, 10}, {7, 7}},

as the second line of my definition of the Graphics style. This works perfectly for images that were manually inserted into the notebook. However, if I try to produce any plots while this style definition is in effect, all hell breaks lose and I end up with lots and lots of error messages. Is there a way to fix the Graphics style so it works for both programattically generated graphics as well as images I insert manually? Ot should I just create an additional Pictures style, say?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.