2
$\begingroup$

It's known that in LaTex, "\includegraphics[]{}",we can adjust the width or size of the figure by using "width=0.75\textwidth". Can we realize such functionality in Mathematica with editing the Stylesheet ?

$\endgroup$

1 Answer 1

3
$\begingroup$

I am not sure if this can be done in a style sheet. When you place a figure in a Mathematica notebook, the width is usually determined by an option ImageSize. Normally a number, say 300 or 500, is used for the value. I have never seen it used, but it is possible to use a value depending on the window size at the moment when you enter the figure:

Plot[x^2 , {x, 0, 1}, ImageSize -> 0.75 CurrentValue[SelectedNotebook[], WindowSize][[1]]]

Be careful: the factor that you want to use, here 0.75, also depends on the setting of the Magnification of the notebook.

When you resize the notebook, neither the width of the figure, nor the fontsize change. But it is possible that the image will resize correponding to the resizing of the notebook. Then you have to wrap the computation of the image width in Dynamic:

Plot[x^2 , {x, 0, 1}, ImageSize -> Dynamic[0.75 CurrentValue[SelectedNotebook[], WindowSize][[1]]]]

Hope this helps a little bit.

$\endgroup$
2
  • $\begingroup$ Thanks for your help. Your method can be used when the importing images are created by Mathematica itself. I try to edit a style in which, whenever I import a figure into a document, it will adjust its size automatically. I shall pursue to solve this with your suggestions. Thank you! $\endgroup$
    – AchillesJJ
    Oct 13, 2014 at 5:06
  • $\begingroup$ @AchillesJJ ImageSize is not restricted to images created by Mathematica itself. It can be used e.g. with Import as well. Try Import["ExampleData/ocelot.jpg", ImageSize -> 700] $\endgroup$ Oct 13, 2014 at 6:16

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.