我正在尝试突出显示表中的一行MSE
,但我无法做到
我在表格末尾得到了一个小框。需要帮助在下面提到的两个表格中的 MSE 行周围绘制一个红色框。[![在此处输入图像描述][1]][1]
答案1
使用tikzmarknode{<name>}{<content>}
和fit
库:
\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{fit,
tikzmark}
\usepackage{booktabs}
\begin{document}
\begin{table}[hp]
\centering
\begin{tabular}{l*{9}{c}}
\toprule
& \multicolumn{9}{c}{PSNR}\\
\cmidrule{3-10}
Optimizer+Loss & Activation & (I32) & (I43) & (I66) & (I87) & (Pg10) & (Pg20) & (Pg30) & (Pg40) \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
\tikzmarknode{A}{MSE} % <---
& Leaky Relu & 32.33 & 28.44 & 21.24 & 18.75 & 30.15 & 24.39 & 21.51
& \tikzmarknode{B}{20.21} \\ % <---
DSSIM & Leaky Relu & 35.5 & 29.5 & 21.74 & 18.44 & 29.9 & 24.21 & 21.27 & 19.02 \\
PSNR loss & Leaky Relu & 33.45 & 29.3 & 21.4 & 18.96 & 30.41 & 24.48 & 21.64 & 20.53 \\
MAE & Leaky Relu & 32.32 & 28.84 & 21.47 & 18.9 & 29.81 & 24.53 & 21.65 & 20.46 \\
MAE & Light Relu & 33.09 & 29.14 & 21.49 & 19.03 & 28.3 & 24.12 & 21.48 & 20.28 \\
MAE & Sine & 32.73 & 28.47 & 21.19 & 18 & 29.06 & 23.92 & 21.08 & 19.9 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
MAE + MGrE & Leaky Relu & 35.7 & 30.52 & 21.54 & 18.99 & 30.5 & 24.46 & 21.85 & 19.86\\
MAE + MGrE + KLL & Leaky Relu & 36.67& 30.4 & 22.44 & 18.92 & 32.59& 27.21 & 24.29 & 22.36\\
MAE + KLL & Leaky Relu & 36.96& 30.61 & 22.41 & 19.26 & 32.66& 27.39 & 24.17 & 22.15\\
MAE & Leaky Reku & 35.7 & 30.18 & 21.54 & 18.83 & 31.72& 24.37 & 21.49 & 20.36\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
MAE + KLL & Leaky Reku & 39.39 & 32.04 & 23.26 & 19.51 & 34.15 & 27.97 & 23.36 & 21.74\\
MAE + 0.5*KLL & Leaky Reku & 38.4 & 31.11 & 22.51 & 19.62 & 33.26 & 25.53 & 22.63 & 21.14\\
MAE + 0.75*KLL & Leaky Reku & 38.41 & 32.54 & 22.5 & 19.27 & 34.13 & 26.13 & 23.68 & 21.79\\
MAE + MGrE + KLL& Leaky Reku & 38.98 & 31.74 & 22.39 & 19.63 & 34.08 & 27.33 & 23.25 & 21.45\\
MAE + MGrE & Leaky Reku & 35.82 & 29.7 & 22.15 & 19.44 & 31.8 & 25.3 & 22.01 & 20.78\\
\midrule
& \multicolumn{9}{c}{PSNR}\\
\cmidrule{3-10}
Optimizer+Loss & Activation & (Pr10) & (Pr20) & (Pr30) & (Pr40) & (Ps025) & (Ps05) & (Ps1) & \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
MSE & Leaky Relu & 27.76 & 22.43 & 19.97 & 18.54 & 34.97 & 33.34 & 30.24 \\
DSSIM & Leaky Relu & 28.16 & 22.74 & 19.15 & 17.55 & 33.45 & 30.16 & 27.37 \\
PSNR loss & Leaky Relu & 28.18 & 22.45 & 20.03 & 18.53 & 35.71 & 34.94 & 30.44 \\
MAE & Leaky Relu & 27.78 & 22.6 & 20.39 & 18.59 & 37.77 &34.19 & 30.87 \\
MAE & Light Relu & 27.68 & 22.41 & 20.2 & 18.45 & 36.46 &33.93 &30.1 \\
MAE & Sine & 27.09 & 21.96 & 19.72 & 18.24 & 34 & 31.57 & 28.57 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
MAE + MGrE & Leaky Relu & 28.21 & 22.26 & 20.22 & 18.63 & 37.24 & 34.87 & 30.97\\
MAE + MGE + KLL & Leaky Relu & 29.46 & 24.11 & 21.32 & 19.04 &36.85 & 34.44 & 31.5\\
MAE + KLL & Leaky Relu & 29.49 & 24.09 & 21.23 & 19.3 & 37.97 & 35.55 & 31.74\\
MAE & Leaky Relu & 28.41 & 22.46 & 19.85 & 18.41 & 37.32 & 35.04 & 30.91\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
MAE + KLL & Leaky Relu & 29.96 & 24.43 & 20.97 & 19.2 & 39.72 & 36.78 & 32.92\\
MAE + 0.5*KLL & Leaky Relu & 29.76 & 23.18 & 20.71 & 18.9 & 39.93 & 36.52 & 32.91\\
MAE + 0.75*KLL & Leaky Relu & 30.29 & 24.11 & 20.94 & 19.28 & 40.12 & 36.83 & 33.18\\
MAE + MGrE + KLL & Leaky Relu & 30.3 & 23.93 & 21.1 & 18.98 & 39.72 & 36.06 & 32.71\\
MAE + MGrE & Leaky Relu & 28.95 &22.75 & 20.26& 18.96 & 39.62 & 35.54 & 31.16\\
\bottomrule
\end{tabular}
\begin{tikzpicture}[overlay,remember picture]
\node[draw=red, fit=(A) (B)] {};
\end{tikzpicture}
\smallskip
\footnotesize
MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error
\end{table}
\end{document}
为了获得结果,您需要至少编译 MWE 两次。
答案2
与。{NiceTabular}
nicematrix
我已将环境替换{tabular}
为{NiceTabular}
,并在行代码前添加了一行以突出显示:
\Block[draw=red,rounded-corners]{1-*}{}
\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tikz}
\usepackage{nicematrix}
\usepackage{booktabs}
\begin{document}
\begin{table}[hp]
\centering
\begin{NiceTabular}{l*{9}{c}}
\toprule
& \multicolumn{9}{c}{PSNR}\\
\cmidrule{3-10}
Optimizer+Loss & Activation & (I32) & (I43) & (I66) & (I87) & (Pg10) & (Pg20) & (Pg30) & (Pg40) \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
\Block[draw=red,rounded-corners]{1-*}{} % <-----
MSE & Leaky Relu & 32.33 & 28.44 & 21.24 & 18.75 & 30.15 & 24.39 & 21.51 & 20.21 \\
DSSIM & Leaky Relu & 35.5 & 29.5 & 21.74 & 18.44 & 29.9 & 24.21 & 21.27 & 19.02 \\
PSNR loss & Leaky Relu & 33.45 & 29.3 & 21.4 & 18.96 & 30.41 & 24.48 & 21.64 & 20.53 \\
MAE & Leaky Relu & 32.32 & 28.84 & 21.47 & 18.9 & 29.81 & 24.53 & 21.65 & 20.46 \\
MAE & Light Relu & 33.09 & 29.14 & 21.49 & 19.03 & 28.3 & 24.12 & 21.48 & 20.28 \\
MAE & Sine & 32.73 & 28.47 & 21.19 & 18 & 29.06 & 23.92 & 21.08 & 19.9 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
MAE + MGrE & Leaky Relu & 35.7 & 30.52 & 21.54 & 18.99 & 30.5 & 24.46 & 21.85 & 19.86\\
MAE + MGrE + KLL & Leaky Relu & 36.67& 30.4 & 22.44 & 18.92 & 32.59& 27.21 & 24.29 & 22.36\\
MAE + KLL & Leaky Relu & 36.96& 30.61 & 22.41 & 19.26 & 32.66& 27.39 & 24.17 & 22.15\\
MAE & Leaky Reku & 35.7 & 30.18 & 21.54 & 18.83 & 31.72& 24.37 & 21.49 & 20.36\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
MAE + KLL & Leaky Reku & 39.39 & 32.04 & 23.26 & 19.51 & 34.15 & 27.97 & 23.36 & 21.74\\
MAE + 0.5*KLL & Leaky Reku & 38.4 & 31.11 & 22.51 & 19.62 & 33.26 & 25.53 & 22.63 & 21.14\\
MAE + 0.75*KLL & Leaky Reku & 38.41 & 32.54 & 22.5 & 19.27 & 34.13 & 26.13 & 23.68 & 21.79\\
MAE + MGrE + KLL& Leaky Reku & 38.98 & 31.74 & 22.39 & 19.63 & 34.08 & 27.33 & 23.25 & 21.45\\
MAE + MGrE & Leaky Reku & 35.82 & 29.7 & 22.15 & 19.44 & 31.8 & 25.3 & 22.01 & 20.78\\
\midrule
& \multicolumn{9}{c}{PSNR}\\
\cmidrule{3-10}
Optimizer+Loss & Activation & (Pr10) & (Pr20) & (Pr30) & (Pr40) & (Ps025) & (Ps05) & (Ps1) & \\
\midrule
\multicolumn{1}{@{}l}{Adam}\\
MSE & Leaky Relu & 27.76 & 22.43 & 19.97 & 18.54 & 34.97 & 33.34 & 30.24 \\
DSSIM & Leaky Relu & 28.16 & 22.74 & 19.15 & 17.55 & 33.45 & 30.16 & 27.37 \\
PSNR loss & Leaky Relu & 28.18 & 22.45 & 20.03 & 18.53 & 35.71 & 34.94 & 30.44 \\
MAE & Leaky Relu & 27.78 & 22.6 & 20.39 & 18.59 & 37.77 &34.19 & 30.87 \\
MAE & Light Relu & 27.68 & 22.41 & 20.2 & 18.45 & 36.46 &33.93 &30.1 \\
MAE & Sine & 27.09 & 21.96 & 19.72 & 18.24 & 34 & 31.57 & 28.57 \\
\addlinespace
\multicolumn{1}{@{}l}{Ranger}\\
MAE + MGrE & Leaky Relu & 28.21 & 22.26 & 20.22 & 18.63 & 37.24 & 34.87 & 30.97\\
MAE + MGE + KLL & Leaky Relu & 29.46 & 24.11 & 21.32 & 19.04 &36.85 & 34.44 & 31.5\\
MAE + KLL & Leaky Relu & 29.49 & 24.09 & 21.23 & 19.3 & 37.97 & 35.55 & 31.74\\
MAE & Leaky Relu & 28.41 & 22.46 & 19.85 & 18.41 & 37.32 & 35.04 & 30.91\\
\addlinespace
\multicolumn{1}{@{}l}{Ranger21}\\
MAE + KLL & Leaky Relu & 29.96 & 24.43 & 20.97 & 19.2 & 39.72 & 36.78 & 32.92\\
MAE + 0.5*KLL & Leaky Relu & 29.76 & 23.18 & 20.71 & 18.9 & 39.93 & 36.52 & 32.91\\
MAE + 0.75*KLL & Leaky Relu & 30.29 & 24.11 & 20.94 & 19.28 & 40.12 & 36.83 & 33.18\\
MAE + MGrE + KLL & Leaky Relu & 30.3 & 23.93 & 21.1 & 18.98 & 39.72 & 36.06 & 32.71\\
MAE + MGrE & Leaky Relu & 28.95 &22.75 & 20.26& 18.96 & 39.62 & 35.54 & 31.16\\
\bottomrule
\end{NiceTabular}
\smallskip
\footnotesize
MSE: Mean Square Error; MAE: Mean Absolute Error; MGE: Mean Gradient Error
\end{table}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。