How to make a picture taking the maximum space?
To expand a picture imported with includegraphics
that is wider than heigh to the width of the text block, you just do this:
includegraphics[width=textwidth]{ ... }
When they are heigher than wide, you could do pretty much the same with the text height:
includegraphics[height=textheight]{ ... }
However, because pictures are often included in floats, there is a caption. This caption has a certain height and includegraphics[height=textheight]{ ... }
make the figure overflow in the margin.
This leads to the following:
- Is there a way to tell to
includegraphics
that the height of the picture must be the difference betweentextheight
and the height of the caption (with the needed space around of course)? - How to generalise this kind of behaviour to the case where there are several floats or subfloats in the same “row” or “column” by saying to
includegraphics
something like “take the maximum allowed space”?
I think it could be more general and maybe someone else could expand or precise this.
daleif suggested to use the adjustbox package. It is very interesting and gives access to the maximum dimensions of pictures.
I tried two interesting things:
To use
adjincludegraphics
in place ofincludegraphics
inside afigure
environment:
begin{figure}
adjincludegraphics[max height=textheight]{ ... }
caption{Some text}
I also tried
max totalheight
, but I don’t see a difference (the manual doesn’t say anything about it.) This doesn’t work: the picture is scaled but the caption is still outside the margins.
To use the
adjustbox
environment which can emulate floats:
begin{adjustbox}{float=figure,caption={Some text}, max height=textheight}
includegraphics{ ... }
end{adjustbox}
This does not work unless I remove
float=figure
(and then there is no caption.) Thefigure
(alone) option doesn’t work either. Withfloat=figure
, there is absolutely nothing appearing in the document but a blank page.
I think the second solution is better, but I can’t get it working properly.
graphics floats scale
add a comment |
To expand a picture imported with includegraphics
that is wider than heigh to the width of the text block, you just do this:
includegraphics[width=textwidth]{ ... }
When they are heigher than wide, you could do pretty much the same with the text height:
includegraphics[height=textheight]{ ... }
However, because pictures are often included in floats, there is a caption. This caption has a certain height and includegraphics[height=textheight]{ ... }
make the figure overflow in the margin.
This leads to the following:
- Is there a way to tell to
includegraphics
that the height of the picture must be the difference betweentextheight
and the height of the caption (with the needed space around of course)? - How to generalise this kind of behaviour to the case where there are several floats or subfloats in the same “row” or “column” by saying to
includegraphics
something like “take the maximum allowed space”?
I think it could be more general and maybe someone else could expand or precise this.
daleif suggested to use the adjustbox package. It is very interesting and gives access to the maximum dimensions of pictures.
I tried two interesting things:
To use
adjincludegraphics
in place ofincludegraphics
inside afigure
environment:
begin{figure}
adjincludegraphics[max height=textheight]{ ... }
caption{Some text}
I also tried
max totalheight
, but I don’t see a difference (the manual doesn’t say anything about it.) This doesn’t work: the picture is scaled but the caption is still outside the margins.
To use the
adjustbox
environment which can emulate floats:
begin{adjustbox}{float=figure,caption={Some text}, max height=textheight}
includegraphics{ ... }
end{adjustbox}
This does not work unless I remove
float=figure
(and then there is no caption.) Thefigure
(alone) option doesn’t work either. Withfloat=figure
, there is absolutely nothing appearing in the document but a blank page.
I think the second solution is better, but I can’t get it working properly.
graphics floats scale
1
Of course you cannot usemax-height=textheight
, then there is no room left for the caption. Perhaps something likemax height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs
– daleif
Feb 6 '15 at 16:55
Also if you use theexport
(AFAIR) option foradjustbox
those options also apply directly toincludegraphics
– daleif
Feb 6 '15 at 16:55
add a comment |
To expand a picture imported with includegraphics
that is wider than heigh to the width of the text block, you just do this:
includegraphics[width=textwidth]{ ... }
When they are heigher than wide, you could do pretty much the same with the text height:
includegraphics[height=textheight]{ ... }
However, because pictures are often included in floats, there is a caption. This caption has a certain height and includegraphics[height=textheight]{ ... }
make the figure overflow in the margin.
This leads to the following:
- Is there a way to tell to
includegraphics
that the height of the picture must be the difference betweentextheight
and the height of the caption (with the needed space around of course)? - How to generalise this kind of behaviour to the case where there are several floats or subfloats in the same “row” or “column” by saying to
includegraphics
something like “take the maximum allowed space”?
I think it could be more general and maybe someone else could expand or precise this.
daleif suggested to use the adjustbox package. It is very interesting and gives access to the maximum dimensions of pictures.
I tried two interesting things:
To use
adjincludegraphics
in place ofincludegraphics
inside afigure
environment:
begin{figure}
adjincludegraphics[max height=textheight]{ ... }
caption{Some text}
I also tried
max totalheight
, but I don’t see a difference (the manual doesn’t say anything about it.) This doesn’t work: the picture is scaled but the caption is still outside the margins.
To use the
adjustbox
environment which can emulate floats:
begin{adjustbox}{float=figure,caption={Some text}, max height=textheight}
includegraphics{ ... }
end{adjustbox}
This does not work unless I remove
float=figure
(and then there is no caption.) Thefigure
(alone) option doesn’t work either. Withfloat=figure
, there is absolutely nothing appearing in the document but a blank page.
I think the second solution is better, but I can’t get it working properly.
graphics floats scale
To expand a picture imported with includegraphics
that is wider than heigh to the width of the text block, you just do this:
includegraphics[width=textwidth]{ ... }
When they are heigher than wide, you could do pretty much the same with the text height:
includegraphics[height=textheight]{ ... }
However, because pictures are often included in floats, there is a caption. This caption has a certain height and includegraphics[height=textheight]{ ... }
make the figure overflow in the margin.
This leads to the following:
- Is there a way to tell to
includegraphics
that the height of the picture must be the difference betweentextheight
and the height of the caption (with the needed space around of course)? - How to generalise this kind of behaviour to the case where there are several floats or subfloats in the same “row” or “column” by saying to
includegraphics
something like “take the maximum allowed space”?
I think it could be more general and maybe someone else could expand or precise this.
daleif suggested to use the adjustbox package. It is very interesting and gives access to the maximum dimensions of pictures.
I tried two interesting things:
To use
adjincludegraphics
in place ofincludegraphics
inside afigure
environment:
begin{figure}
adjincludegraphics[max height=textheight]{ ... }
caption{Some text}
I also tried
max totalheight
, but I don’t see a difference (the manual doesn’t say anything about it.) This doesn’t work: the picture is scaled but the caption is still outside the margins.
To use the
adjustbox
environment which can emulate floats:
begin{adjustbox}{float=figure,caption={Some text}, max height=textheight}
includegraphics{ ... }
end{adjustbox}
This does not work unless I remove
float=figure
(and then there is no caption.) Thefigure
(alone) option doesn’t work either. Withfloat=figure
, there is absolutely nothing appearing in the document but a blank page.
I think the second solution is better, but I can’t get it working properly.
graphics floats scale
graphics floats scale
edited 16 mins ago
Martin Scharrer♦
198k45632814
198k45632814
asked Feb 5 '15 at 15:56
Zoxume
800314
800314
1
Of course you cannot usemax-height=textheight
, then there is no room left for the caption. Perhaps something likemax height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs
– daleif
Feb 6 '15 at 16:55
Also if you use theexport
(AFAIR) option foradjustbox
those options also apply directly toincludegraphics
– daleif
Feb 6 '15 at 16:55
add a comment |
1
Of course you cannot usemax-height=textheight
, then there is no room left for the caption. Perhaps something likemax height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs
– daleif
Feb 6 '15 at 16:55
Also if you use theexport
(AFAIR) option foradjustbox
those options also apply directly toincludegraphics
– daleif
Feb 6 '15 at 16:55
1
1
Of course you cannot use
max-height=textheight
, then there is no room left for the caption. Perhaps something like max height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs– daleif
Feb 6 '15 at 16:55
Of course you cannot use
max-height=textheight
, then there is no room left for the caption. Perhaps something like max height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs– daleif
Feb 6 '15 at 16:55
Also if you use the
export
(AFAIR) option for adjustbox
those options also apply directly to includegraphics
– daleif
Feb 6 '15 at 16:55
Also if you use the
export
(AFAIR) option for adjustbox
those options also apply directly to includegraphics
– daleif
Feb 6 '15 at 16:55
add a comment |
2 Answers
2
active
oldest
votes
See the adjustbox
package, it can add features to includegraphics
, including an max width/max height
option that might be useful in your case.
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
add a comment |
The order of the used keys is important. As you create a float the resizing must be done beforehand, i.e. max height
first, then define the caption
and finally tell adjustbox
that you want a figure (figure
key or float=figure
).
If you use the caption
key after figure
it comes to late. max height
after figure
will create a figure
environment inside a resizebox
which does not work.
You should use textheight-baselineskip
as maximum height as you still need space for the caption (increase to 2baselineskip
if you have a two line caption and so on).
Note that there is also adjustimage
which reduces the amount of code.
documentclass{article}
usepackage{adjustbox}
usepackage{mwe}% for example text and image only
begin{document}
blindtext
begin{adjustbox}{max height=textheight-baselineskip,center,caption={Some text},float=figure}
includegraphics{example-image-a3}
end{adjustbox}
% or just
%adjustimage{max height=textheight-baselineskip,center,caption={Some %text},float=figure}{example-image-a3}
blindtext
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f226707%2fhow-to-make-a-picture-taking-the-maximum-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
See the adjustbox
package, it can add features to includegraphics
, including an max width/max height
option that might be useful in your case.
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
add a comment |
See the adjustbox
package, it can add features to includegraphics
, including an max width/max height
option that might be useful in your case.
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
add a comment |
See the adjustbox
package, it can add features to includegraphics
, including an max width/max height
option that might be useful in your case.
See the adjustbox
package, it can add features to includegraphics
, including an max width/max height
option that might be useful in your case.
answered Feb 5 '15 at 15:59
daleif
32.2k252115
32.2k252115
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
add a comment |
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
Thank you for your answer, but I have issues with adjustbox. I edited my first post with more details.
– Zoxume
Feb 6 '15 at 16:47
add a comment |
The order of the used keys is important. As you create a float the resizing must be done beforehand, i.e. max height
first, then define the caption
and finally tell adjustbox
that you want a figure (figure
key or float=figure
).
If you use the caption
key after figure
it comes to late. max height
after figure
will create a figure
environment inside a resizebox
which does not work.
You should use textheight-baselineskip
as maximum height as you still need space for the caption (increase to 2baselineskip
if you have a two line caption and so on).
Note that there is also adjustimage
which reduces the amount of code.
documentclass{article}
usepackage{adjustbox}
usepackage{mwe}% for example text and image only
begin{document}
blindtext
begin{adjustbox}{max height=textheight-baselineskip,center,caption={Some text},float=figure}
includegraphics{example-image-a3}
end{adjustbox}
% or just
%adjustimage{max height=textheight-baselineskip,center,caption={Some %text},float=figure}{example-image-a3}
blindtext
end{document}
add a comment |
The order of the used keys is important. As you create a float the resizing must be done beforehand, i.e. max height
first, then define the caption
and finally tell adjustbox
that you want a figure (figure
key or float=figure
).
If you use the caption
key after figure
it comes to late. max height
after figure
will create a figure
environment inside a resizebox
which does not work.
You should use textheight-baselineskip
as maximum height as you still need space for the caption (increase to 2baselineskip
if you have a two line caption and so on).
Note that there is also adjustimage
which reduces the amount of code.
documentclass{article}
usepackage{adjustbox}
usepackage{mwe}% for example text and image only
begin{document}
blindtext
begin{adjustbox}{max height=textheight-baselineskip,center,caption={Some text},float=figure}
includegraphics{example-image-a3}
end{adjustbox}
% or just
%adjustimage{max height=textheight-baselineskip,center,caption={Some %text},float=figure}{example-image-a3}
blindtext
end{document}
add a comment |
The order of the used keys is important. As you create a float the resizing must be done beforehand, i.e. max height
first, then define the caption
and finally tell adjustbox
that you want a figure (figure
key or float=figure
).
If you use the caption
key after figure
it comes to late. max height
after figure
will create a figure
environment inside a resizebox
which does not work.
You should use textheight-baselineskip
as maximum height as you still need space for the caption (increase to 2baselineskip
if you have a two line caption and so on).
Note that there is also adjustimage
which reduces the amount of code.
documentclass{article}
usepackage{adjustbox}
usepackage{mwe}% for example text and image only
begin{document}
blindtext
begin{adjustbox}{max height=textheight-baselineskip,center,caption={Some text},float=figure}
includegraphics{example-image-a3}
end{adjustbox}
% or just
%adjustimage{max height=textheight-baselineskip,center,caption={Some %text},float=figure}{example-image-a3}
blindtext
end{document}
The order of the used keys is important. As you create a float the resizing must be done beforehand, i.e. max height
first, then define the caption
and finally tell adjustbox
that you want a figure (figure
key or float=figure
).
If you use the caption
key after figure
it comes to late. max height
after figure
will create a figure
environment inside a resizebox
which does not work.
You should use textheight-baselineskip
as maximum height as you still need space for the caption (increase to 2baselineskip
if you have a two line caption and so on).
Note that there is also adjustimage
which reduces the amount of code.
documentclass{article}
usepackage{adjustbox}
usepackage{mwe}% for example text and image only
begin{document}
blindtext
begin{adjustbox}{max height=textheight-baselineskip,center,caption={Some text},float=figure}
includegraphics{example-image-a3}
end{adjustbox}
% or just
%adjustimage{max height=textheight-baselineskip,center,caption={Some %text},float=figure}{example-image-a3}
blindtext
end{document}
answered 17 mins ago
Martin Scharrer♦
198k45632814
198k45632814
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f226707%2fhow-to-make-a-picture-taking-the-maximum-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Of course you cannot use
max-height=textheight
, then there is no room left for the caption. Perhaps something likemax height=0.9textheight,max width=textwidth,keepaspectratio
is better for your needs– daleif
Feb 6 '15 at 16:55
Also if you use the
export
(AFAIR) option foradjustbox
those options also apply directly toincludegraphics
– daleif
Feb 6 '15 at 16:55