표의 색상 값

표의 색상 값

테이블에서 값 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

xcolor@Marijn의 조언( 패키지를 로드하고 4.9731다음으로 변경) 을 따르는 것 외에도 \textcolor{blue}{4.9731}주로 불필요한 래퍼를 제거하여 테이블의 LaTeX 코드를 크게 단순화해야 합니다 \multicolumn{1}. 여담: 기본 LaTeX 코드를 생성하기 위해 tablegenerators.com(또는 유사한 사이트)을 사용하셨나요? 그렇다면 다음 조언도 따르십시오. 다시는 그런 일을 하지 마십시오. :-)

여기에 이미지 설명을 입력하세요

\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}

여러 가지 편집이 필요합니다.

위 코드의 출력

관련 정보