表格中的着色值

表格中的着色值

我试图将表格中的值 4.9731 涂成蓝色,但目前没有任何效果。图片显示了表格供您参考。在此处输入图片描述

\begin{table}[h]
\begin{tabular}{cc|cccccc|}
\cline{3-8}
\multicolumn{2}{c|}{}                                                          & \multicolumn{6}{c|}{\textbf{Number of Hidden Units}}                                                                                                                                                                      \\
\cline{3-8} 
\multicolumn{2}{c|}{}                                                          & \multicolumn{3}{c|}{\textbf{25}}                                                                    & \multicolumn{3}{c|}{\textbf{50}}                                                                           \\ \cline{3-8} 
\multicolumn{2}{c|}{}                                                          & \multicolumn{3}{c|}{\textbf{Lookback Steps}}                                                        & \multicolumn{3}{c|}{\textbf{Lookback Steps}}                                                               \\ \cline{3-8} 
\multicolumn{2}{c|}{\multirow{}{}{}} & \multicolumn{1}{c|}{\textbf{0}} & \multicolumn{1}{c|}{\textbf{2}} & \multicolumn{1}{c|}{\textbf{5}} & \multicolumn{1}{c|}{\textbf{0}}                            & \multicolumn{1}{c|}{\textbf{2}} & \textbf{5} \\ \hline
\multicolumn{1}{|c|}{\multirow{}{}{}}                                         & {\textbf{0.5}}  & \multicolumn{1}{c|}{5.0170}     & \multicolumn{1}{c|}{5.0351}     & \multicolumn{1}{c|}{5.0180}     & \multicolumn{1}{c|}{4.9731} & \multicolumn{1}{c|}{5.0292}     & {5.0211}     \\ \cline{2-8} 
\multicolumn{1}{|c|}{\textbf{Learning Rate}}                                             & \textbf{0.1}  & \multicolumn{1}{c|}{5.2190}     & \multicolumn{1}{c|}{5.2145}     & \multicolumn{1}{c|}{5.2146}     & \multicolumn{1}{c|}{5.1329}                                 & \multicolumn{1}{c|}{5.1366}     & 5.1368     \\ \cline{2-8} 
\multicolumn{1}{|c|}{} & \textbf{0.05} & \multicolumn{1}{c|}{5.4077}     & \multicolumn{1}{c|}{5.4038}     & \multicolumn{1}{c|}{5.4038}     & \multicolumn{1}{c|}{5.3130}                                 & \multicolumn{1}{c|}{5.3142}     & 5.3142     \\ \hline
\end{tabular}
\caption{All possible combinations of parameters settings using different learning rates, number of hidden units and lookback steps in truncated backpropagation}
\label{table:table1}
\end{table}


答案1

除了遵循@Marijn的建议——加载包xcolor并更改4.9731\textcolor{blue}{4.9731}——您还应该大大简化表格的LaTeX代码,主要是通过摆脱大量不必要的\multicolumn{1}包装器。旁白:您是否使用tablegenerators.com(或一些类似的网站)来生成基本的LaTeX代码?如果是,请同时听取以下建议:不要再这样做了。:-)

在此处输入图片描述

\documentclass{article}
\usepackage{array}  % for '\extrarowheight' macro
\usepackage{xcolor} % for '\textcolor' macro

% 2 handy shortcut macros:
\newcommand\mcii{\multicolumn{2}{l|}{}}
\newcommand\mciii[1]{\multicolumn{3}{c|}{\textbf{#1}}}

\begin{document}

\begin{table}[h]
\setlength\tabcolsep{5pt}  % default value: 6pt
\setlength\extrarowheight{2pt} % for a less-cramped "look"
\centering
\begin{tabular}{|l|l|*{6}{c|}}
\cline{3-8}
\mcii & \multicolumn{6}{c|}{\textbf{Number of Hidden Units}} \\
\cline{3-8} 
\mcii & \mciii{25} & \mciii{50} \\ 
\cline{3-8} 
\mcii & \mciii{Lookback Steps} & \mciii{Lookback Steps} \\ 
\cline{3-8} 
\mcii & \textbf{0} & \textbf{2} & \textbf{5} 
      & \textbf{0} & \textbf{2} & \textbf{5} \\ 
\hline
 & \textbf{0.5}  & 5.0170 & 5.0351 & 5.0180  
                 & \textcolor{blue}{4.9731} & 5.0292 & 5.0211  \\ 
\cline{2-8} 
\textbf{Learning Rate}                                                  
 & \textbf{0.1}  & 5.2190 & 5.2145 & 5.2146   
                 & 5.1329 & 5.1366 & 5.1368  \\  
\cline{2-8} 
 & \textbf{0.05} & 5.4077 & 5.4038 & 5.4038
                 & 5.3130 & 5.3142 & 5.3142  \\ 
\hline
\end{tabular}

\caption{All possible combinations of parameters settings using different learning rates, number of hidden units and lookback steps in truncated backpropagation}
\label{table:table1}

\end{table}

\end{document}

答案2

供参考,这里有一种使用 创建表格{NiceTabular}的方法nicematrix(但是,我建议本着 的精神进行设计booktabs)。

\documentclass{article}
\usepackage{geometry}
\usepackage{nicematrix}

\begin{document}

\begin{table}[h]
\begin{NiceTabular}{>{\bfseries}c>{\bfseries}ccccccc}% <- the % is mandatory here
  [
    hvlines,
    corners,
    caption = { All possible combinations of parameters settings using different learning rates, 
              number of hidden units and lookback steps in truncated backpropagation }
  ]
\RowStyle[nb-rows=4]{\bfseries}
              &      & \Block{1-6}{Number Hidden Units}  \\ 
              &      & \Block{1-3}{25} &&& \Block{1-3}{50} \\ 
              &      & \Block{1-3}{Lookback Steps} &&& \Block{1-3}{Lookback Steps} \\ 
              &      & 0  & 2 & 5 & 0 & 2 & 5 \\ 
\Block{3-1}{} & 0.5  & 5.0170 & 5.0351 & 5.0180 & \color{blue}4.9731 & 5.0292 & 5.0211 \\ 
Learning Rate & 0.1  & 5.2190 & 5.2145 & 5.2146 & 5.1329 & 5.1366 & 5.1368 \\ 
              & 0.05 & 5.4077 & 5.4038 & 5.4038 & 5.3130 & 5.3142 & 5.3142 \\ 
\end{NiceTabular}
\label{table:table1}
\end{table}

\end{document}

您需要多次编译。

上述代码的输出

相关内容