TeX - LaTeX Asked on April 7, 2021
My two subfigures wont line up next to eachother, one is higher than the other. One doesn’t need rotating but the other one does. When I rotate them both then they line up correctly but they don’t otherwise.
This is the code I’m using which has worked for all my other figures.
Update: I have tried rotating the original picture outside LaTex but that doesn’t seem to change anything.
begin{figure}[H]
begin{subfigure}[t]{0.5textwidth}
centering
% include first image
includegraphics[width=0.8linewidth]{Lill ex 2 3}
caption{Our first solution.}
label{Lill fig:sub-first}
end{subfigure}hfill
begin{subfigure}[t]{0.5textwidth}
centering
% include second image
includegraphics[angle=270, width=0.8linewidth]{Lill ex 2 5}
caption{Finding more solutions. }
label{Lill fig:sub-second}
end{subfigure}hfill
caption{Second step of Lill's method for example ref{example 2}.}
label{Lill ex 2}
end{figure}
As you suggested in your question already, the problem stems from rotating the second subfigure only, after which the baseline of the picture is not set to the 'new bottom' automatically.
However, instead of adjusting the position inside the figure
, the simplest solution would be to turn the second picture outside of LaTeX, save the file, and then includegraphics
it without specifying the angle
(since the picture looks like it should have that orientation anyways).
Answered by schoekling on April 7, 2021
You need to change subfigure
positioning accordingly: from t
to b
:
documentclass{article}
usepackage{graphicx}
usepackage{subcaption}
begin{document}
begin{figure}[ht]
begin{subfigure}[b]{0.5textwidth}
centering
% include first image
includegraphics[width=0.8linewidth]{example-image-duck}%{Lill ex 2 3}
caption{Our first solution.}
label{Lill fig:sub-first}
end{subfigure}hfill
begin{subfigure}[b]{0.5textwidth}
centering
% include second image
includegraphics[angle=270, width=0.8linewidth]{example-image-duck}%{Lill ex 2 5}
caption{Finding more solutions. }
label{Lill fig:sub-second}
end{subfigure}hfill
caption{Second step of Lill's method for example ref{example 2}.}
label{Lill ex 2}
end{figure}
end{document}
Answered by Zarko on April 7, 2021
You can use subcaptionbox
, that also copes with longer captions.
documentclass{article}
usepackage{graphicx,subcaption}
begin{document}
begin{figure}[htp]
subcaptionbox{Our first solution.label{Lill fig:sub-first}}[0.5textwidth][c]{%
includegraphics[width=0.8linewidth]{example-image-1x1}%
}hfill
subcaptionbox{Finding more solutions.label{Lill fig:sub-second}}[0.5textwidth][c]{%
includegraphics[angle=270, width=0.8linewidth]{example-image-1x1}%
}
caption{Second step of Lill's method for example ref{example 2}.}
label{Lill ex 2}
end{figure}
end{document}
If one of the captions has to be longer than one line, the output would be like
However in this case something less than 0.5textwidth
should be used or longer captions will clash with one another.
Answered by egreg on April 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP