2

When i want to run this code, i got error about undefined control sequence in \subfloat tag. How can i solve it.

\documentclass[preprint,12pt]{elsarticle}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
%\usepackage{mathtools}
%\usepackage{xspace}
\usepackage{booktabs}
\usepackage{adjustbox}
%\usepackage{subcaption}
\usepackage{subfigure}

\begin{document}

\begin{table}[!ht]
\centering
   \subfloat[First Subtable\label{tab:chapter4:1a}]{
     \tiny
     \centering
     \begin{tabular}{|c|c|c|}\hline
       a&b&c\\
       d&e&f\\\hline
     \end{tabular}
   }
   \subfloat[Second Subtable\label{tab:chapter4:1b}]{
     \tiny
     \centering
     \begin{tabular}{|c|c|c|}\hline
       g&h&i\\
       j&k&l\\\hline
     \end{tabular}
   }
   \subfloat[Third Subtable\label{tab:chapter4:1c}]{
     \tiny
     \centering
     \begin{tabular}{|c|c|c|}\hline
       m&n&o\\
       p&q&r\\\hline
     \end{tabular}
   }
   \caption{Testing}\label{tab:chapter4:1}
\end{table}
\end{document}
  • 1
    Welcome to TeX.SE! In standard article document class I can't reproduce your error. However, result is not nice ... Please extend your code snippet to complete small document beginning with \documentclass{...} and ending with \end{document} – Zarko Jul 13 '19 at 4:01
  • \documentclass[preprint,12pt]{elsarticle}\end{document} – Shahriar Setu Jul 13 '19 at 4:17
  • Please edit your question and add this and other missed packages to your code fragment. – Zarko Jul 13 '19 at 4:20
  • In your MWE (Minimal Working Example) is missed \usepackage{subfig} in its preamble. – Zarko Jul 13 '19 at 4:28
  • 1
    you add subfigure (which not define subfloat and it is also obsolete), not subfig. – Zarko Jul 13 '19 at 4:36
1

In your MWE (Minimal Working Example) you load package subfigure, which is obsolete and also not define environment subfloat. For it you nit to load subfig (observe difference in package's name). You should not load both packages!.

Try the following MWE:


\documentclass[preprint]{elsarticle}
\usepackage{subfig}   % <--- missed package, it is not compatible with "subfigure" !
%\captionsetup[subfloat]{justification=RaggedRight}

\begin{document}
\begin{table}[!ht]
\centering
%\tiny
   \subfloat[First Subtable\label{tab:chapter4:1a}]{
     \begin{tabular}{|c|c|c|}\hline
       a&b&c\\
       d&e&f\\  \hline
     \end{tabular}
   }\hfil
   \subfloat[Second Subtable\label{tab:chapter4:1b}]{
     \begin{tabular}{|c|c|c|}\hline
       g&h&i\\
       j&k&l\\  \hline
     \end{tabular}
   }\hfil
   \subfloat[Third Subtable\label{tab:chapter4:1c}]{
     \begin{tabular}{|c|c|c|}\hline
       m&n&o\\
       p&q&r\\  \hline
     \end{tabular}
   }
   \caption{Testing}\label{tab:chapter4:1}
\end{table}
\end{document}

which works without any error and gives:

enter image description here

  • working :). Thanks a lot Zarko. – Shahriar Setu Jul 13 '19 at 5:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.