[Tex/LaTex] How to do 2X3 subfloats for a figure

floatspositioningsubfloats

I have 6 figures of the same size and I would like them to be subfiqures in a figure in the format so that they are all aligned with 3 figures on the first row and 3 figures directly below.

I have tried the following which gives me 3 figures in each row but are all misaligned (I use the subfig package but it causes a problem as I have the subcaption pacakage too):

    \usepackage{tabularx}
\usepackage{subfig}
\begin{figure}
\def\tabularxcolumn#1{m{#1}}
\begin{tabularx}{\linewidth}{@{}cXX@{}}

\begin{tabular}{ccc}
\centering
\subfloat[A]{\includegraphics[width=3cm]{image1}}
& \subfloat[B]{\includegraphics[width=3cm]{image2}} & \subfloat[C]{\includegraphics[width=3cm]{image3}} \
\newline
& \subfloat[D]{\includegraphics[width=3cm]{image4}}   \subfloat[E]{\includegraphics[width=3cm]{image5}}
& \subfloat[F]{\includegraphics[width=3cm]{image6}}\    \end{tabular}

\end{tabularx}
\caption{Many figures}\label{figure}
\end{figure}


Edit: I complete my code snippet to MWE and add image of figures.

I'm pretty sure, that your question is duplicate ... anyway, try the following:

\documentclass{article}
\usepackage{subfig}
\usepackage{graphicx}
\begin{document}

\begin{figure}

\centering
\subfloat[A]{\includegraphics[width=3cm]{example-image-a}}\hfil
\subfloat[B]{\includegraphics[width=3cm]{example-image-b}}\hfil
\subfloat[C]{\includegraphics[width=3cm]{example-image-c}}

\subfloat[D]{\includegraphics[width=3cm]{example-image-a}}\hfil
\subfloat[E]{\includegraphics[width=3cm]{example-image-b}}\hfil
\subfloat[F]{\includegraphics[width=3cm]{example-image-c}}
\caption{Many figures}\label{figure}
\end{figure}
\end{document}


which gives:

As you can see, the use of tabularx and tabular is superfluous.