如何在桌号和子桌号之间添加一个点?

如何在桌号和子桌号之间添加一个点?

我想在文本中引用子表。但是,当我使用该ref命令时,表号和子表的显示没有任何分隔。这超出了我的预期,因为我希望两个数字之间有一个点或空格,例如,我希望它显示“表 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}

在此处输入图片描述

相关内容