如何在表號和子表號之間加點?

如何在表號和子表號之間加點?

我想在我的文本中引用一個子表。但是,當我使用該ref命令時,表和子表的編號沒有任何分離地顯示。這超出了我的預期,因為我希望兩個數字之間有一個點或空格,例如,我希望它能顯示“表一.(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}

在此輸入影像描述

相關內容