I have 5 subfigures with width set to be 0.2 \textwidth
, I want them to be in one row, but I have to set their width smaller than 0.2 to do that.
Does anyone know the reason?
Thank you!
[Tex/LaTex] why subfigure doesn’t occupy the full textwidth
floatssubfloats
Best Answer
You didn't state which package you use to help create the
subfigure
environments:subfigure
-- which is deprecated and ought not to be used anymore --subfig
, orsubcaption
. I'll assume you're usingsubcaption
.One needs to remember that TeX converts single line breaks into space tokens. Thus, if each
subfigure
environment is terminated with a newline directive, the total width is 5*0.2\textwidth + 4*(width of space token), which exceeds\textwidth
.You have two choices: insert a
%
(comment character) at the end of the first foursubfigure
environments (to suppress the implicit insertion of a space character) or choose a width for eachsubfigure
that's slightly less than0.2\textwidth
. I actually prefer the second approach.