2

I want to have sub-figure exactly above the caption, but now I have it on the left side of the caption.

enter image description here

\begin{figure}[H]
\centering
\begin{subfigure}{0.45\textwidth}
\includegraphics[scale=0.7]{astmdowel}
\caption{} \label{fig:}
\end{subfigure}
\hspace*{0cm} % separation between the subfigures
\hfill
\begin{subfigure}{0.45\textwidth}
\includegraphics[scale=0.7]{BSdowel}
\caption{} \label{fig:}
\end{subfigure}
\caption{Specimen according to: a)ASTM D 5764 -97a b)BS EN 383:2007.} \label{fig:40}
\end{figure}

Thank you for your comments, I checked using fbox and the pictures don't have any extra space:

enter image description here

Here is working example:

\documentclass[12pt, a4paper]{report}
% ctrl+T comment, ctrl+U uncomment
\usepackage{tikz}
\usepackage{slashbox}
\usepackage{caption}
\usepackage{float}
\usepackage{enumerate}
\usepackage{bm}

\usepackage[export]{adjustbox}

\usepackage{multirow}
\usepackage{array}

\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{\alph{subfigure})}

\usepackage{fixltx2e}
\captionsetup[subfigure]{skip=1pt} %%global setting for subfigure
\usepackage{amsmath, siunitx} 



\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage[labelfont=it]{caption}
\usepackage[font=it]{caption}

%\usepackage{showframe}% http://ctan.org/pkg/showframe
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter head
\patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter* head
\makeatother


\pretolerance=10000 % stop latex from braking the words
\tolerance=2000 % stop latex from braking the words
\emergencystretch=10pt % stop latex from braking the words
\usepackage{titlesec}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{geometry}
 \geometry{a4paper,
bottom=25mm,
right=31.7mm,
 left=31.7mm,
 top=25mm,
 }
\DeclareMathSizes{10}{10}{10}{10}


\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{18pt}{\Huge}



\begin{document}

\begin{figure}[H]
\centering
\begin{subfigure}{0.45\textwidth}
\fbox{\includegraphics[scale=0.7]{astmdowel}}

\caption{} \label{fig:}
\end{subfigure}
\hspace*{0cm} % separation between the subfigures
\hfill
\begin{subfigure}{0.45\textwidth}
\fbox{\includegraphics[scale=0.7]{BSdowel}}
\caption{} \label{fig:}
\end{subfigure}
\caption{Specimen according to: a)ASTM D 5764 -97a b)BS EN 383:2007.} \label{fig:40}
\end{figure}

\end{document}
2
  • 3
    Welcome to TeX.SE. If I use example-image from package graphicx instead yours (which are not available too us) I get expected result: image sub-captions are centered below images. This means, that you image has (huge) white space on the right side. To see this, try to enclose inclusion of graphics into fbox like \fbox{\includegraphics[scale=0.4]{example-image-a}}. And please, help hus to help you ... alwas provide complete minimal (non) working example (MWE) which we can copy to our computers and test it.
    – Zarko
    Jul 13, 2016 at 22:42
  • Could you please provide a compilable MWE? Jul 14, 2016 at 12:33

1 Answer 1

1

I can not reproduce your problem even with your original preamble.

Since in it are many packages as caption, subcaption loaded many times with non-consistent options I first clean up it, than comment all packages and your definitions which aren't necessary to show your image and than make caption and subcaptionoptions consistent.

In second step I make small changes in include graphics. Here I suggest to use instead option scale option width, which better handle centering of images on page (with it there is small offset - image are slightly shift to left).

Complete code is:

\documentclass[12pt, a4paper]{report}
% ctrl+T comment, ctrl+U uncomment
%\usepackage{tikz}
%\usepackage{slashbox}
%\usepackage{enumerate}
%\usepackage{bm}
%\usepackage[export]{adjustbox}

%\usepackage{array}
%\usepackage{booktabs}
%\usepackage{multirow}

%\usepackage{amsmath}
%\DeclareMathSizes{10}{10}{10}{10}

\usepackage{graphicx}
%\usepackage{float}
\usepackage[font=it]{caption}
\usepackage[labelformat=brace]{subcaption}
%\captionsetup[subfigure]{skip=1pt} %%global setting for subfigure
%\usepackage{siunitx}

%\usepackage{xcolor}

%\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
%\makeatletter
%\patchcmd{\@makechapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter head
%\patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{}{}{}% Removes space above \chapter* head
%\makeatother

%\pretolerance=10000 % stop latex from braking the words
%\tolerance=2000 % stop latex from braking the words
%\emergencystretch=10pt % stop latex from braking the words
%\usepackage{titlesec}

\usepackage{geometry}
\geometry{  a4paper,
            bottom=25mm,
            right=31.7mm,
            left=31.7mm,
            top=25mm,
            showframe% <-- for show page layout
            }

%\titleformat{\chapter}[display]
%{\normalfont\huge\bfseries}{}{18pt}{\Huge}


\begin{document}
    \begin{figure}%[htb]% <-- changed
    \centering
\begin{subfigure}{0.45\textwidth}% <-- changed
\includegraphics[width=\linewidth]{example-image-a}% <-- changed to example image
\caption{} \label{fig:}
\end{subfigure}
\hfil% <-- changed 
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=\linewidth]{example-image-b}
\caption{} \label{fig:}
\end{subfigure}
\caption{Specimen according to: a)ASTM D 5764 -97a b)BS EN 383:2007.} \label{fig:40}
    \end{figure}
\end{document}

Result:

enter image description here

I suggest that first you test above MWE with your original images. if you not get the same positioned images, than you have something very strange in your images.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .