1

I am new to latex and I am using Overleaf to write my document.

I have managed to get the subtables properly but have been unsuccessful in getting brackets for the subtables caption, for instance (a): X (b): Y. Instead, I am getting a: X b: Y.

\documentclass[10pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{csquotes}% Recommended
\usepackage{graphicx}
\usepackage{caption}
\usepackage[justification=centering]{caption}
\usepackage{subcaption} %multiple images in figure
\usepackage[labelformat=simple]{subcaption}
\renewcommand\thesubfigure{(\alph{subfigure})}
\usepackage{float}
\usepackage{chngcntr}
\usepackage{enumitem} %Indent lists
\usepackage{siunitx} %SI Units
\usepackage{booktabs,siunitx}
\setlength{\parskip}{10pt plus 1pt minus 1pt} %Line after each paragraph
\usepackage{unicode-math}
\usepackage{fixltx2e}% for \textsubscript
\usepackage[fleqn]{amsmath}
\usepackage{boldline} 
\usepackage{array}
    \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
    \newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
%\newcommand{\mysection}[2]{\setcounter{section}{#1}\addtocounter{section}{-1}\section{#2}}
\usepackage{comment}
\usepackage[noadjust]{cite}

\usepackage{geometry} \geometry{ a4paper, total={170mm,257mm}, left=20mm, top=20mm, } \usepackage{multirow} \usepackage{soul} \usepackage{caption} \usepackage[dvipsnames]{xcolor} ...

\begin{document} .... \begin{table}[h] \caption{Bla bla bla. Something value:} \begin{subtable}{.5\linewidth} \centering \caption{:\SI{1}{\meter}} \begin{tabular}{|c|c|} \hline Distance & Speed \ \hline 6 & 10.00 \ 5 & 10.00 \ 4 & 10.00 \ 3 & 10.00 \ 2 & 10.00 \ 1 & 10.00 \ \hline \end{tabular} \end{subtable}% \begin{subtable}{.5\linewidth} \centering \caption{:\SI{4.5}{\meter}} \begin{tabular}{|c|c|} \hline Distance & Speed \ \hline 6 & 10.00 \ 5 & 10.00 \ 4 & 10.00 \ 3 & 10.00 \ 2 & 10.00 \ 1 & 10.00 \ \hline \end{tabular} \end{subtable} \end{table} ...

I have followed https://www.overleaf.com/learn/latex/How_to_Write_a_Thesis_in_LaTeX_(Part_3):_Figures,_Subfigures_and_Tables and looked at How can I have two tables side by side? but still no success. Any help? enter image description here

MMM
  • 11
  • 1
    Welcome to TeX SX! Did you load the subcaption package? – Bernard Apr 16 '21 at 12:09
  • 1
    You have problems with document preamble, not with showed code fragment. If I put it in `\documentclass{article} \usepackage{caption, subcaption} \usepackage{siunitx}

    \begin{document} your code fragment \end{document}thesubtable` captions' labels are in parenthesis. Please extend your code fragment to complete small document, which reproduce your problem.

    – Zarko Apr 16 '21 at 13:40
  • @Bernard Many thanks! Yes I have ```\documentclass[10pt]{article} \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage{amsmath} \usepackage{csquotes}% Recommended \usepackage{graphicx} \usepackage{caption} \usepackage[justification=centering]{caption} \usepackage{subcaption} %multiple images in figure \usepackage[labelformat=simple]{subcaption} \renewcommand\thesubfigure{(\alph{subfigure})} \usepackage{float} \usepackage{chngcntr} \usepackage{enumitem} %Indent lists \usepackage{siunitx} %SI Units
    
    
    – MMM Apr 16 '21 at 14:19
  • @Zarko I have edited my code and added the packages I used at the beginning of the document. – MMM Apr 16 '21 at 14:22
  • The defaul format for subcaption labels is [labelformat=parens], so, in my opinion, remove labelformat=simple. – Bernard Apr 16 '21 at 14:25
  • Worked like a charm. Much appreciated, Bernard. – MMM Apr 16 '21 at 14:47

1 Answers1

1
  • you have serious problems with your document preamble:
    • many packages are load twice with different options
    • order the loading of packages is wrong, you have clash between packages
  • As @Bernard noted, problem is your definition of subcaption: instead
\usepackage[labelformat=simple]{subcaption}

you probably looking for default settings for subcaption (see MWE below)

\documentclass[10pt]{article}
\usepackage{geometry}
\geometry{a4paper,
          total={170mm,257mm},
          left=20mm,top=20mm,
          }
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}
\usepackage{unicode-math} % xelatex
\usepackage[justification=centering]{caption}
\usepackage{subcaption}   % <---
\usepackage{array, boldline, booktabs, multirow}
    \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
    \newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}

\begin{table}[ht] \caption{Bla bla bla. Something value:} \begin{subtable}{.5\linewidth} \centering \caption{:\SI{1}{\meter}} \begin{tabular}{|c|c|} \hline Distance & Speed \ \hline 6 & 10.00 \ 5 & 10.00 \ 4 & 10.00 \ 3 & 10.00 \ 2 & 10.00 \ 1 & 10.00 \ \hline \end{tabular} \end{subtable}% \begin{subtable}{.5\linewidth} \centering \caption{:\SI{4.5}{\meter}} \begin{tabular}{|c|c|} \hline Distance & Speed \ \hline 6 & 10.00 \ 5 & 10.00 \ 4 & 10.00 \ 3 & 10.00 \ 2 & 10.00 \ 1 & 10.00 \ \hline \end{tabular} \end{subtable} \end{table} \end{document}

enter image description here

Is this what you looking for?

Zarko
  • 296,517