TeX - LaTeX Asked by potatasbravas on April 26, 2021
Im using TexStudio 2.12.22. When trying to make subfigures I get the following error:
! Illegal unit of measure (pt inserted).
! Missing number, treated as zero.
to be read again>
*
l.157 begin{subfigure}{0.5*textwidth}”
usepackage{subcaption}
begin{figure}[h]
begin{subfigure}{0.5*textwidth}
includegraphics[width=textwidth]{example-image-a}
end{subfigure}
hfill
begin{subfigure}{0.5*textwidth}
includegraphics[width=textwidth]{example-image-b}
end{subfigure}
end{figure}
Any ideas? Thanks
UPDATE
Thanks to Leandris, the * was messing it up. replaced with {0.5textwidth}
Remove the *
. begin{subfigure}{0.5textwidth}
instead of begin{subfigure}{0.5*textwidth}
works perfectly fine.
Placing two subfigures next to each other that both take up half the textwidth will result in an overfull box warning as there will be a small white spce between them. This can be overcome when removing the hfill
and when placing a %
sign at the end of the first subfigure
environment. Alternatively you could also decrease the width of both subfigures.
(Red lines indicate the start of the margins.)
documentclass{article}
usepackage{graphicx}
usepackage{subcaption}
begin{document}
begin{figure}[h]
begin{subfigure}{0.5textwidth}
includegraphics[width=textwidth]{example-image-a}
end{subfigure}
hfill
begin{subfigure}{0.5textwidth}
includegraphics[width=textwidth]{example-image-b}
end{subfigure}
end{figure}
begin{figure}[h]
begin{subfigure}{0.5textwidth}
includegraphics[width=textwidth]{example-image-a}
end{subfigure}%
% hfill
begin{subfigure}{0.5textwidth}
includegraphics[width=textwidth]{example-image-b}
end{subfigure}
end{figure}
begin{figure}[h]
begin{subfigure}{0.45textwidth}
includegraphics[width=textwidth]{example-image-a}
end{subfigure}
hfill
begin{subfigure}{0.45textwidth}
includegraphics[width=textwidth]{example-image-b}
end{subfigure}
end{figure}
end{document}
Answered by leandriis on April 26, 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