TransWikia.com

Shift of labels in subfig

TeX - LaTeX Asked by xolms on May 7, 2021

I have

documentclass[12pt]{article}
usepackage[left=10mm, top=20mm, right=10mm, bottom=20mm]{geometry}
usepackage{graphicx}
usepackage{subfig}
usepackage[font=scriptsize]{caption}
captionsetup{width=0.8textwidth}
begin{document}

begin{figure}[h!]
centering
subfloat[xxx]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[yyy]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[zzz]{includegraphics[width=0.25textwidth]{1.jpg}}
caption{.}
label{appendix}
end{figure}
end{document}

and obtain
enter image description here

Could you help me, what can I do with this horizontal shift for (a) xxx, (b) yyy, (c) zzz?

UPD:
Such example

documentclass[12pt]{article}
usepackage[left=10mm, top=20mm, right=10mm, bottom=20mm]{geometry}
usepackage{graphicx}
usepackage{subfig}
usepackage[font=scriptsize]{caption}
%captionsetup{width=0.8textwidth}

begin{document}
title{title}
author{authors}
date{}
maketitle
abstract{abstract}
section{Introduction}
just main text just main text just main text just main text just main text just main text just main text just main text just main text just main text just main text
begin{figure}[h!]
centering
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
caption{just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption}
label{appendix}
end{figure}
end{document}

Result
enter image description here

It seems it caused by the width of the title.

One Answer

As I said in my comment, caption text cannot be wider than textwidth. Cause of your problem is command command abstract{abstract} which shrink followed text to width of abstract text.

Correct MWE for your case is:

documentclass[12pt]{article}
usepackage[hmargin=10mm, vmargin=20mm]{geometry}
usepackage[demo]{graphicx}
usepackage{subfig}
usepackage[font=scriptsize]{caption}
%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%
usepackage{lipsum} % for generating dummy text

begin{document}
title{title}
author{authors}
date{}
maketitle

begin{abstract} % <--- correct syntax
lipsum[66]
end{abstract}   % <---

section{Introduction}
lipsum[11]
    begin{figure}[ht]
    centering
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
qquad
subfloat[]{includegraphics[width=0.25textwidth]{1.jpg}}
caption{just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption just a caption}
label{appendix}
    end{figure}
end{document}

which gives expected result:

enter image description here

(red lines shows page layout).

As you can see, the width caption text is equal to width of text. Also subcaptions are on the right place. Is this what you after?

Correct answer by Zarko on May 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP