我想突出显示每行中最小的数字。我该怎么做呢?例如,我想突出显示 3 和 3。
\documentclass{article}
\usepackage{datatool}
\begin{filecontents*}{test2.csv}
Fruits, Adam, steve
apples, 17, 3
oranges, 3, 18
\end{filecontents*}
\DTLloaddb{mydata2}{test2.csv}
\begin{document}
\begin{tabular}{ll}
\bfseries Adam & \bfseries Steve & \bfseries Fruits%
\DTLforeach{mydata2}{\Adam=Adam,\Steve=Steve, \Fruits=Fruits}%
{%
\\\Fruits & \Adam & \Steve
}%
\end{tabular}
\end{document}
答案1
由于您只有两个数字列,因此您可以执行以下操作:
\documentclass{article}
\usepackage{xcolor}
\usepackage{datatool}
\begin{filecontents*}{test2.csv}
Fruits, Adam, Steve
apples, 17, 3
oranges, 3, 18
\end{filecontents*}
\DTLloaddb{mydata2}{test2.csv}
\begin{document}
\begin{tabular}{lll}
\bfseries Fruits & \bfseries Adam & \bfseries Steve%
\DTLforeach{mydata2}{\Adam=Adam,\Steve=Steve, \Fruits=Fruits}%
{%
\\\Fruits &
\dtlifnumlt{\Adam}{\Steve}{\color{red}}{}\Adam &
\dtlifnumlt{\Steve}{\Adam}{\color{red}}{}\Steve
}%
\end{tabular}
\end{document}
得出的结果为:
如果您有两个以上的数字列,您可以使用它们\DTLgminall
来计算行的最小值,如下所示:
\documentclass{article}
\usepackage{xcolor}
\usepackage{datatool}
\begin{filecontents*}{test2.csv}
Fruits, Adam, Steve
apples, 17, 3
oranges, 3, 18
\end{filecontents*}
\DTLloaddb{mydata2}{test2.csv}
\begin{document}
\begin{tabular}{lll}
\bfseries Fruits & \bfseries Adam & \bfseries Steve%
\DTLforeach{mydata2}{\Adam=Adam,\Steve=Steve, \Fruits=Fruits}%
{%
\\\Fruits &
\DTLgminall{\rowmin}{\Adam,\Steve}%
\dtlifnumeq{\Adam}{\rowmin}{\color{red}}{}\Adam &
\dtlifnumeq{\Steve}{\rowmin}{\color{red}}{}\Steve
}%
\end{tabular}
\end{document}