How to automatically scale subfigures to have same height? [duplicate]
This question already has an answer here:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
3 answers
I have a lot of figures to put side by side in a document, and they are all slightly different in size (i.e. not all 4:3 format or so).
What I'm doing at the moment is tweak the width=0.XXtextwidth
of both until they look more or less the same height.
Here I provide an example code: what I would like to be able to do is have a macro or something, where I can simply provide the two figures and they automatically scale to have the same height and fit on one line. Is that possible? And if yes, how?
Edit: since people are asking why I'm not providing specific sizes for the images: The code should work with any 2 images with any aspect ratio. Give it two images and the code scales them to fit side by side and have the same height, filling the horizontal space available.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[width=0.45textwidth]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[width=0.45textwidth]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
What I get:
What I wish to happen automatically:
subfloats scaling
New contributor
marked as duplicate by leandriis, samcarter, JouleV, Stefan Pinnow, Kurt 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
3 answers
I have a lot of figures to put side by side in a document, and they are all slightly different in size (i.e. not all 4:3 format or so).
What I'm doing at the moment is tweak the width=0.XXtextwidth
of both until they look more or less the same height.
Here I provide an example code: what I would like to be able to do is have a macro or something, where I can simply provide the two figures and they automatically scale to have the same height and fit on one line. Is that possible? And if yes, how?
Edit: since people are asking why I'm not providing specific sizes for the images: The code should work with any 2 images with any aspect ratio. Give it two images and the code scales them to fit side by side and have the same height, filling the horizontal space available.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[width=0.45textwidth]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[width=0.45textwidth]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
What I get:
What I wish to happen automatically:
subfloats scaling
New contributor
marked as duplicate by leandriis, samcarter, JouleV, Stefan Pinnow, Kurt 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago
add a comment |
This question already has an answer here:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
3 answers
I have a lot of figures to put side by side in a document, and they are all slightly different in size (i.e. not all 4:3 format or so).
What I'm doing at the moment is tweak the width=0.XXtextwidth
of both until they look more or less the same height.
Here I provide an example code: what I would like to be able to do is have a macro or something, where I can simply provide the two figures and they automatically scale to have the same height and fit on one line. Is that possible? And if yes, how?
Edit: since people are asking why I'm not providing specific sizes for the images: The code should work with any 2 images with any aspect ratio. Give it two images and the code scales them to fit side by side and have the same height, filling the horizontal space available.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[width=0.45textwidth]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[width=0.45textwidth]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
What I get:
What I wish to happen automatically:
subfloats scaling
New contributor
This question already has an answer here:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
3 answers
I have a lot of figures to put side by side in a document, and they are all slightly different in size (i.e. not all 4:3 format or so).
What I'm doing at the moment is tweak the width=0.XXtextwidth
of both until they look more or less the same height.
Here I provide an example code: what I would like to be able to do is have a macro or something, where I can simply provide the two figures and they automatically scale to have the same height and fit on one line. Is that possible? And if yes, how?
Edit: since people are asking why I'm not providing specific sizes for the images: The code should work with any 2 images with any aspect ratio. Give it two images and the code scales them to fit side by side and have the same height, filling the horizontal space available.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[width=0.45textwidth]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[width=0.45textwidth]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
What I get:
What I wish to happen automatically:
This question already has an answer here:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
3 answers
subfloats scaling
subfloats scaling
New contributor
New contributor
edited 2 days ago
Kurt
39.1k850164
39.1k850164
New contributor
asked 2 days ago
Superuser27Superuser27
43313
43313
New contributor
New contributor
marked as duplicate by leandriis, samcarter, JouleV, Stefan Pinnow, Kurt 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by leandriis, samcarter, JouleV, Stefan Pinnow, Kurt 2 days ago
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago
add a comment |
1
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago
1
1
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago
add a comment |
3 Answers
3
active
oldest
votes
For the two sample graphs and the default text width and height given by the scrreprt
document class, it suffices to replace width=...
with height=0.21textheight
, for both subfig
groups.
For other combinations of text widths, text heights, and proportions of the pairs of images that need to be placed next to each other, you'll probably have to experiment a bit to find out which value of height=...
is about right.
I'm assuming that the objective is to make the pairs of graphs be as large as possible, i.e., span the full width of the textblock. If this assumption is valid, none of the centering
instructions are needed.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
subfloat[Figure one]{%
includegraphics[height=0.21textheight]{example-image-a}}
hspace*{fill}
subfloat[Figure two with different side proportions]{%
includegraphics[height=0.21textheight]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}end{figure}
end{document}
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around0.9textwidth
and they should have the same height. Automatically. :)
– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of theheight=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.
– Mico
2 days ago
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
|
show 2 more comments
with defining (only) their height. like includegraphics[height=33mm]{example-image-a}}
(select the image height according to your wish).
off-topic: don't use centering
inside of subfloats ...
edit:
In your case, since you like to have in both images the same height
to use key Gin
as follows in edited code below. To push images apart as much as possible, use hfill
instead of quad
.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Figures}
begin{figure}[h!]
setkeys{Gin}{height=44mm}
subfloat[Figure one]{includegraphics{example-image-a}}
hfill% push sub images apart, so take all the line
subfloat[Figure two with different side proportions]{%
includegraphics{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
(red lines indicate text borders)
why not to usecentering
inside a float?
– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.subfloat
take a size of included image (as far as I know, but i can be wrong).
– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
|
show 3 more comments
To get both images to the same height you can store the height of the first image in a dimension imageheight
. Then you can use height=imageheight
for the second image.
The culprit here is that you can not automaticly define the width of both images to fit the textwidth as good as possible. Perhaps an code with lua can do that but until now I did not learn to use lua in TeX ...
So let us do it semi automatic ...
Lets have a look into the code. With the line in the preamble
newdimenimageheight
we declare a new dimension imageheight
to store the height of the first image.
With the code
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
you get the current height of the image for a choosen width of width=0.40textwidth
.
Now you can use the code
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}}
to print the images with same heigth. To get them fitting the textwifth just play with the width for the first image: width=0.40textwidth
. Change the value of 0.40textwidth
to your needs.
The complete code
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
usepackage{showframe}
newdimenimageheight % to store the actual image height <==============
begin{document}
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}} % <=============
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}} % <==========
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
gives you the result:
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
For the two sample graphs and the default text width and height given by the scrreprt
document class, it suffices to replace width=...
with height=0.21textheight
, for both subfig
groups.
For other combinations of text widths, text heights, and proportions of the pairs of images that need to be placed next to each other, you'll probably have to experiment a bit to find out which value of height=...
is about right.
I'm assuming that the objective is to make the pairs of graphs be as large as possible, i.e., span the full width of the textblock. If this assumption is valid, none of the centering
instructions are needed.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
subfloat[Figure one]{%
includegraphics[height=0.21textheight]{example-image-a}}
hspace*{fill}
subfloat[Figure two with different side proportions]{%
includegraphics[height=0.21textheight]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}end{figure}
end{document}
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around0.9textwidth
and they should have the same height. Automatically. :)
– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of theheight=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.
– Mico
2 days ago
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
|
show 2 more comments
For the two sample graphs and the default text width and height given by the scrreprt
document class, it suffices to replace width=...
with height=0.21textheight
, for both subfig
groups.
For other combinations of text widths, text heights, and proportions of the pairs of images that need to be placed next to each other, you'll probably have to experiment a bit to find out which value of height=...
is about right.
I'm assuming that the objective is to make the pairs of graphs be as large as possible, i.e., span the full width of the textblock. If this assumption is valid, none of the centering
instructions are needed.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
subfloat[Figure one]{%
includegraphics[height=0.21textheight]{example-image-a}}
hspace*{fill}
subfloat[Figure two with different side proportions]{%
includegraphics[height=0.21textheight]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}end{figure}
end{document}
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around0.9textwidth
and they should have the same height. Automatically. :)
– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of theheight=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.
– Mico
2 days ago
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
|
show 2 more comments
For the two sample graphs and the default text width and height given by the scrreprt
document class, it suffices to replace width=...
with height=0.21textheight
, for both subfig
groups.
For other combinations of text widths, text heights, and proportions of the pairs of images that need to be placed next to each other, you'll probably have to experiment a bit to find out which value of height=...
is about right.
I'm assuming that the objective is to make the pairs of graphs be as large as possible, i.e., span the full width of the textblock. If this assumption is valid, none of the centering
instructions are needed.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
subfloat[Figure one]{%
includegraphics[height=0.21textheight]{example-image-a}}
hspace*{fill}
subfloat[Figure two with different side proportions]{%
includegraphics[height=0.21textheight]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}end{figure}
end{document}
For the two sample graphs and the default text width and height given by the scrreprt
document class, it suffices to replace width=...
with height=0.21textheight
, for both subfig
groups.
For other combinations of text widths, text heights, and proportions of the pairs of images that need to be placed next to each other, you'll probably have to experiment a bit to find out which value of height=...
is about right.
I'm assuming that the objective is to make the pairs of graphs be as large as possible, i.e., span the full width of the textblock. If this assumption is valid, none of the centering
instructions are needed.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
begin{document}
chapter{Figures}
begin{figure}[h!]
subfloat[Figure one]{%
includegraphics[height=0.21textheight]{example-image-a}}
hspace*{fill}
subfloat[Figure two with different side proportions]{%
includegraphics[height=0.21textheight]{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}end{figure}
end{document}
edited 2 days ago
answered 2 days ago
MicoMico
282k31386774
282k31386774
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around0.9textwidth
and they should have the same height. Automatically. :)
– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of theheight=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.
– Mico
2 days ago
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
|
show 2 more comments
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around0.9textwidth
and they should have the same height. Automatically. :)
– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of theheight=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.
– Mico
2 days ago
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
1
1
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
The question was how I can get them to the same height and fill the page width without having to experiment a bit :)
– Superuser27
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
@Superuser27 - If you rule out experimenting of the type described above, you'll have to "play it safe" by providing more horizontal whitespace than is absolutely necessary. Put differently, what you'll be showing your readers is deliberately less detailed than would be possible with just a bit of experimenting. In my experience, readers always appreciate being shown graphs that are as large as sensibly possible. Why disappoint them by showing them more whitespace instead? Naturally, you're free to do as you please -- and your readers are free to make up their own opinions...
– Mico
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around
0.9textwidth
and they should have the same height. Automatically. :)– Superuser27
2 days ago
Ok I try to rephrase the question: I would like to get the pictures to fill the page width, yet stay side by side (so the sum of their width should be around
0.9textwidth
and they should have the same height. Automatically. :)– Superuser27
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of the
height=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.– Mico
2 days ago
@Superuser27 - You've also failed to provide any exact information about the aspect ratios of the images, the width of the text block, and height of the text block. If such information were provided, one could in fact come up with a near-optimal calculation of the
height=...
option for various combinations of graphs. However, you chose not to provide these pieces of information.– Mico
2 days ago
1
1
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
@Superuser27: You might be interested in Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
– leandriis
2 days ago
|
show 2 more comments
with defining (only) their height. like includegraphics[height=33mm]{example-image-a}}
(select the image height according to your wish).
off-topic: don't use centering
inside of subfloats ...
edit:
In your case, since you like to have in both images the same height
to use key Gin
as follows in edited code below. To push images apart as much as possible, use hfill
instead of quad
.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Figures}
begin{figure}[h!]
setkeys{Gin}{height=44mm}
subfloat[Figure one]{includegraphics{example-image-a}}
hfill% push sub images apart, so take all the line
subfloat[Figure two with different side proportions]{%
includegraphics{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
(red lines indicate text borders)
why not to usecentering
inside a float?
– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.subfloat
take a size of included image (as far as I know, but i can be wrong).
– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
|
show 3 more comments
with defining (only) their height. like includegraphics[height=33mm]{example-image-a}}
(select the image height according to your wish).
off-topic: don't use centering
inside of subfloats ...
edit:
In your case, since you like to have in both images the same height
to use key Gin
as follows in edited code below. To push images apart as much as possible, use hfill
instead of quad
.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Figures}
begin{figure}[h!]
setkeys{Gin}{height=44mm}
subfloat[Figure one]{includegraphics{example-image-a}}
hfill% push sub images apart, so take all the line
subfloat[Figure two with different side proportions]{%
includegraphics{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
(red lines indicate text borders)
why not to usecentering
inside a float?
– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.subfloat
take a size of included image (as far as I know, but i can be wrong).
– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
|
show 3 more comments
with defining (only) their height. like includegraphics[height=33mm]{example-image-a}}
(select the image height according to your wish).
off-topic: don't use centering
inside of subfloats ...
edit:
In your case, since you like to have in both images the same height
to use key Gin
as follows in edited code below. To push images apart as much as possible, use hfill
instead of quad
.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Figures}
begin{figure}[h!]
setkeys{Gin}{height=44mm}
subfloat[Figure one]{includegraphics{example-image-a}}
hfill% push sub images apart, so take all the line
subfloat[Figure two with different side proportions]{%
includegraphics{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
(red lines indicate text borders)
with defining (only) their height. like includegraphics[height=33mm]{example-image-a}}
(select the image height according to your wish).
off-topic: don't use centering
inside of subfloats ...
edit:
In your case, since you like to have in both images the same height
to use key Gin
as follows in edited code below. To push images apart as much as possible, use hfill
instead of quad
.
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
begin{document}
chapter{Figures}
begin{figure}[h!]
setkeys{Gin}{height=44mm}
subfloat[Figure one]{includegraphics{example-image-a}}
hfill% push sub images apart, so take all the line
subfloat[Figure two with different side proportions]{%
includegraphics{example-image-16x9}}
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
(red lines indicate text borders)
edited 2 days ago
Mico
282k31386774
282k31386774
answered 2 days ago
ZarkoZarko
127k868166
127k868166
why not to usecentering
inside a float?
– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.subfloat
take a size of included image (as far as I know, but i can be wrong).
– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
|
show 3 more comments
why not to usecentering
inside a float?
– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.subfloat
take a size of included image (as far as I know, but i can be wrong).
– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
why not to use
centering
inside a float?– samcarter
2 days ago
why not to use
centering
inside a float?– samcarter
2 days ago
@samcarter, because it hasn't any influence on positioning of image.
subfloat
take a size of included image (as far as I know, but i can be wrong).– Zarko
2 days ago
@samcarter, because it hasn't any influence on positioning of image.
subfloat
take a size of included image (as far as I know, but i can be wrong).– Zarko
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
Why 33mm? How can I get them to fill most of the width as possible?
– Superuser27
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
@Superuser27 - How is one supposed to determine how to "fill as much of the width as possible" if one doesn't have any information about (a) the height and width of the text block and (b) the aspect ratios of the images?
– Mico
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
apparently i din't understand the question correctly, what you like to have... so i left to select desired height to you ...
– Zarko
2 days ago
|
show 3 more comments
To get both images to the same height you can store the height of the first image in a dimension imageheight
. Then you can use height=imageheight
for the second image.
The culprit here is that you can not automaticly define the width of both images to fit the textwidth as good as possible. Perhaps an code with lua can do that but until now I did not learn to use lua in TeX ...
So let us do it semi automatic ...
Lets have a look into the code. With the line in the preamble
newdimenimageheight
we declare a new dimension imageheight
to store the height of the first image.
With the code
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
you get the current height of the image for a choosen width of width=0.40textwidth
.
Now you can use the code
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}}
to print the images with same heigth. To get them fitting the textwifth just play with the width for the first image: width=0.40textwidth
. Change the value of 0.40textwidth
to your needs.
The complete code
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
usepackage{showframe}
newdimenimageheight % to store the actual image height <==============
begin{document}
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}} % <=============
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}} % <==========
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
gives you the result:
add a comment |
To get both images to the same height you can store the height of the first image in a dimension imageheight
. Then you can use height=imageheight
for the second image.
The culprit here is that you can not automaticly define the width of both images to fit the textwidth as good as possible. Perhaps an code with lua can do that but until now I did not learn to use lua in TeX ...
So let us do it semi automatic ...
Lets have a look into the code. With the line in the preamble
newdimenimageheight
we declare a new dimension imageheight
to store the height of the first image.
With the code
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
you get the current height of the image for a choosen width of width=0.40textwidth
.
Now you can use the code
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}}
to print the images with same heigth. To get them fitting the textwifth just play with the width for the first image: width=0.40textwidth
. Change the value of 0.40textwidth
to your needs.
The complete code
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
usepackage{showframe}
newdimenimageheight % to store the actual image height <==============
begin{document}
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}} % <=============
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}} % <==========
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
gives you the result:
add a comment |
To get both images to the same height you can store the height of the first image in a dimension imageheight
. Then you can use height=imageheight
for the second image.
The culprit here is that you can not automaticly define the width of both images to fit the textwidth as good as possible. Perhaps an code with lua can do that but until now I did not learn to use lua in TeX ...
So let us do it semi automatic ...
Lets have a look into the code. With the line in the preamble
newdimenimageheight
we declare a new dimension imageheight
to store the height of the first image.
With the code
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
you get the current height of the image for a choosen width of width=0.40textwidth
.
Now you can use the code
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}}
to print the images with same heigth. To get them fitting the textwifth just play with the width for the first image: width=0.40textwidth
. Change the value of 0.40textwidth
to your needs.
The complete code
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
usepackage{showframe}
newdimenimageheight % to store the actual image height <==============
begin{document}
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}} % <=============
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}} % <==========
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
gives you the result:
To get both images to the same height you can store the height of the first image in a dimension imageheight
. Then you can use height=imageheight
for the second image.
The culprit here is that you can not automaticly define the width of both images to fit the textwidth as good as possible. Perhaps an code with lua can do that but until now I did not learn to use lua in TeX ...
So let us do it semi automatic ...
Lets have a look into the code. With the line in the preamble
newdimenimageheight
we declare a new dimension imageheight
to store the height of the first image.
With the code
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
you get the current height of the image for a choosen width of width=0.40textwidth
.
Now you can use the code
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}}
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}}
to print the images with same heigth. To get them fitting the textwifth just play with the width for the first image: width=0.40textwidth
. Change the value of 0.40textwidth
to your needs.
The complete code
documentclass{scrreprt}
usepackage{subfig}
usepackage{graphicx}
usepackage{showframe}
newdimenimageheight % to store the actual image height <==============
begin{document}
settoheight{imageheight}{% <==========================================
includegraphics[width=0.40textwidth,keepaspectratio]{example-image-a}%
}
chapter{Figures}
begin{figure}[h!]
centering
subfloat[Figure one]{%
centeringincludegraphics[height=imageheight]{example-image-a}} % <=============
qquad
subfloat[Figure two with different side proportions]{%
centeringincludegraphics[height=imageheight]{example-image-16x9}} % <==========
caption{How to get the two figures to same height (respecting proportions)?}
end{figure}
end{document}
gives you the result:
answered 2 days ago
KurtKurt
39.1k850164
39.1k850164
add a comment |
add a comment |
1
Have a look at tex.stackexchange.com/a/218414/36296 In contrast to just setting the height, this will still ensure that your images will still span the whole textwidth
– samcarter
2 days ago