pgfplotstable:突出显示整行和整列

pgfplotstable:突出显示整行和整列

这是对这个问题。使用pgfplotstable,我想创建一个样式来突出显示整行和/或整列。Zarko 在链接问题中的回答显示了如何博尔登整行。将这种方法扩展到整列似乎很简单……但如果我将行和列加粗,相交的单元格将“不加粗”。救命。

梅威瑟:

    \documentclass{standalone}
    \usepackage{pgfplotstable}
    \pgfplotsset{compat=1.16}

    \begin{filecontents*}{data.dat}
       A,    B,  C
    0.10, 1000,  1
    0.20, 2000,  2
    0.30, 3000,  3
    \end{filecontents*}
    \pgfplotstableread[col sep=comma]{data.dat}\mytable

    % Highlight entire row
    \pgfplotstableset{% 
        highlightrow/.style={
            postproc cell content/.append code={
               \count0=\pgfplotstablerow
                \advance\count0 by1
                \ifnum\count0=#1
                \pgfkeysalso{@cell content/.add={$\bf}{$}}%
                \fi
            },
        },
    }

    % Highlight entire column
    \pgfplotstableset{% 
        highlightcol/.style={
            postproc cell content/.append code={
               \count0=\pgfplotstablecol
                \advance\count0 by1
                \ifnum\count0=#1
                \pgfkeysalso{@cell content/.add={$\bf}{$}}%
                \fi
            },
        },
    }

    \begin{document}
    \pgfplotstabletypeset[
        columns/1/.style = {string type, column type = {l}},
        highlightrow = {2},
        highlightcol = {2},
        ]\mytable
    \end{document}

在此处输入图片描述

答案1

像这样? (编辑:固定空格,非常感谢@PatrickT!)

\documentclass{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.16}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
   A,    B,  C
0.10, 1000,  1
0.20, 2000,  2
0.30, 3000,  3
\end{filecontents*}
\pgfplotstableread[col sep=comma]{data.dat}\mytable

% Highlight entire row
\pgfplotstableset{% 
    highlightrow/.style={
        postproc cell content/.append code={
           \count0=\pgfplotstablerow%
            \advance\count0 by1%
            \ifnum\count0=#1%
            \pgfkeysalso{@cell content/.add={\ifmmode\else\boldmath\fi$}{$}}%
            \fi%
        },
    },
}

% Highlight entire column
\pgfplotstableset{% 
    highlightcol/.style={
        postproc cell content/.append code={
           \count0=\pgfplotstablecol
            \advance\count0 by1
            \ifnum\count0=#1
            \pgfkeysalso{@cell content/.add={\ifmmode\else\boldmath\fi$}{$}}
            \fi
        },
    },
}

\begin{document}
\pgfplotstabletypeset[
    columns/1/.style = {string type, column type = {l}},
    highlightrow = {2},
    highlightcol = {2},
    ]\mytable
\end{document}

在此处输入图片描述

相关内容