修改图片(和表格)标题枚举

修改图片(和表格)标题枚举

我怎样才能将单词“图形和表格”涂成一种颜色,将其中的数字涂成另一种颜色?(见附图)。

非常感谢在此处输入图片描述

\documentclass{book}
\usepackage{graphicx}
\usepackage{capt-of}% or \usepackage{caption}
\usepackage{booktabs}
\usepackage{varwidth}

\begin{document}

\chapter{Chapter one}

\begin{table}[ht!]
  \begin{varwidth}[b]{0.6\linewidth}
    \centering
    \begin{tabular}{ l r r r }
      \toprule
      Student & Hours/week & Grade \\
      \midrule
      Ada Lovelace & 2 & A \\
      Linus Thorvalds & 8 & A \\
      Bruce Willis & 12 & F \\
      Richard Stallman & 10 & B \\
      Grace Hopper & 12 & A \\
      Alan Turing & 8 & C \\
      Bill Gates & 6 & D \\
      Steve Jobs & 4 & E \\
      \bottomrule
    \end{tabular}
    \caption{Student Database}
    \label{table:student}
  \end{varwidth}%
  \hfill
  \begin{minipage}[b]{0.4\linewidth}
    \centering
    \includegraphics[width=40mm]{example-image}
    \captionof{figure}{2-D scatterplot of the Student Database}
    \label{fig:image}
  \end{minipage}
\end{table}

\end{document}

答案1

我建议采取一种方法,保留创建交叉引用tablefigure对象的能力,而无需将相关数字呈现为青色。

在此处输入图片描述

\documentclass{book}
\usepackage{graphicx,booktabs,xcolor}

%% new code:
\renewcommand\tablename{\textcolor{purple}{Table}}
\renewcommand\figurename{\textcolor{purple}{Figure}}
\usepackage[font=small,labelfont={color=cyan}]{caption}

\usepackage[noabbrev]{cleveref} % optional, for \cref macro

\begin{document}

\stepcounter{chapter} % just for this example

\begin{table}[ht!]
  \begin{minipage}[b]{0.5\linewidth}
    %\centering
    \begin{tabular}{@{} l r r @{}}
      \toprule
      Student & Hours/week & Grade \\
      \midrule
      Ada Lovelace & 2 & A \\
      Linus Thorvalds & 8 & A \\
      Bruce Willis & 12 & F \\
      Richard Stallman & 10 & B \\
      Grace Hopper & 12 & A \\
      Alan Turing & 8 & C \\
      Bill Gates & 6 & D \\
      Steve Jobs & 4 & E \\
      \bottomrule
    \end{tabular}
    \caption{Student Database}
    \label{table:student}
  \end{minipage}
  \hfill
  \begin{minipage}[b]{0.4\linewidth}
    %\centering
    \includegraphics[width=\linewidth]{example-image}
    \captionof{figure}{2-D scatterplot of the Student Database}
    \label{fig:image}
  \end{minipage}
\end{table}

Cross-references to table \ref{table:student} and figure \ref{fig:image}.

Cross-references to \cref{table:student,fig:image}.
\end{document}

答案2

像这样?

在此处输入图片描述

\documentclass{book}
\usepackage{graphicx}
\usepackage{booktabs}

\usepackage{xcolor}
\usepackage{caption}
\captionsetup{font=small,
              labelfont={color=purple}}
\DeclareCaptionLabelSeparator{colon}{\color{cyan}: }
\renewcommand\thetable{\textcolor{cyan}{\thechapter.\arabic{table}}}
\renewcommand\thefigure{\textcolor{cyan}{\thechapter.\arabic{table}}}

\begin{document}

\chapter{Chapter one}

\begin{table}[ht!]
  \begin{minipage}[b]{0.6\linewidth}
    \centering
    \begin{tabular}{ l r r }
      \toprule
      Student & Hours/week & Grade \\
      \midrule
      Ada Lovelace & 2 & A \\
      Linus Thorvalds & 8 & A \\
      Bruce Willis & 12 & F \\
      Richard Stallman & 10 & B \\
      Grace Hopper & 12 & A \\
      Alan Turing & 8 & C \\
      Bill Gates & 6 & D \\
      Steve Jobs & 4 & E \\
      \bottomrule
    \end{tabular}
    \caption{Student Database}
    \label{table:student}
  \end{minipage}%
  \hfill
  \begin{minipage}[b]{0.4\linewidth}
    \centering
    \includegraphics[width=40mm]{example-image}
    \captionof{figure}{2-D scatterplot of the Student Database}
    \label{fig:image}
  \end{minipage}
\end{table}

\end{document}

编辑: 现在标签分隔符具有与标题编号相同的颜色。

相关内容