テーブル番号とサブテーブル番号の間にドットを追加するにはどうすればよいですか?

テーブル番号とサブテーブル番号の間にドットを追加するにはどうすればよいですか?

テキスト内のサブテーブルを参照したいのですが、refコマンドを使用すると、テーブル番号とサブテーブル番号が分離されずに表示されます。これは予想外です。2つの数字の間にドットまたはスペースがあることを期待していたので、たとえば次のように表示されることを望みます。「表I.(a)」それよりも「表Ia」したがって、この問題を解決できる解決策はあるでしょうか?

\ref{tab:week2}
\begin{table}[h]
  \begin{subtable}[h]{0.45\textwidth}
      \centering
      \begin{tabular}{l | l | l}
      Day & Max Temp & Min Temp \\
      \hline \hline
      Mon & 20 & 13\\
      Tue & 22 & 14\\
     \end{tabular}
     \caption{First Week}
     \label{tab:week1}
  \end{subtable}
  \hfill
  \begin{subtable}[h]{0.45\textwidth}
      \centering
      \begin{tabular}{l | l | l}
      Day & Max Temp & Min Temp \\
      \hline \hline
      Mon & 17 & 11\\
      Tue & 16 & 10\\
      \end{tabular}
      \caption{Second Week}
      \label{tab:week2}
   \end{subtable}
   \caption{Max and min temps recorded in the first two weeks of July}
   \label{tab:temps}
\end{table}

答え1

提供すべきだった完全なMWE

ただし、解決策は次のとおりです。

\documentclass{article}

\usepackage[labelformat=simple]{subcaption} % packages subfigure and subfig are obsolete

\renewcommand\thesubtable{(\alph{subtable})}
\makeatletter
\renewcommand\p@subtable{\thetable.}
\makeatother


\begin{document}

\ref{tab:week2}
\begin{table}[h]
  \begin{subtable}[h]{0.45\textwidth}
      \centering
      \begin{tabular}{l | l | l}
      Day & Max Temp & Min Temp \\
      \hline \hline
      Mon & 20 & 13\\
      Tue & 22 & 14\\
     \end{tabular}
     \caption{First Week}
     \label{tab:week1}
  \end{subtable}
  \hfill
  \begin{subtable}[h]{0.45\textwidth}
      \centering
      \begin{tabular}{l | l | l}
      Day & Max Temp & Min Temp \\
      \hline \hline
      Mon & 17 & 11\\
      Tue & 16 & 10\\
      \end{tabular}
      \caption{Second Week}
      \label{tab:week2}
   \end{subtable}
   \caption{Max and min temps recorded in the first two weeks of July}
   \label{tab:temps}
\end{table}

\end{document}

ここに画像の説明を入力してください

関連情報