![修改图片(和表格)标题枚举](https://linux22.com/image/443043/%E4%BF%AE%E6%94%B9%E5%9B%BE%E7%89%87%EF%BC%88%E5%92%8C%E8%A1%A8%E6%A0%BC%EF%BC%89%E6%A0%87%E9%A2%98%E6%9E%9A%E4%B8%BE.png)
我怎样才能将单词“图形和表格”涂成一种颜色,将其中的数字涂成另一种颜色?(见附图)。
\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
我建议采取一种方法,保留创建交叉引用table
和figure
对象的能力,而无需将相关数字呈现为青色。
\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}
编辑: 现在标签分隔符具有与标题编号相同的颜色。