pgfplotstable: highlight entire rows and columns












2















This is a follow-up on this question. With pgfplotstable, I would like to create a style to highlight an entire row and/or column. Zarko's answer at the linked question shows how to bolden an entire row. It seemed pretty straightforward to extend that approach to an entire column... except that if I bolden rows and columns, the intersecting cells are "un-bolden". Help.



MWE:



    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
advancecount0 by1
ifnumcount0=#1
pgfkeysalso{@cell content/.add={$bf}{$}}%
fi
},
},
}

% Highlight entire column
pgfplotstableset{%
highlightcol/.style={
postproc cell content/.append code={
count0=pgfplotstablecol
advancecount0 by1
ifnumcount0=#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}


enter image description here










share|improve this question

























  • @Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

    – PatrickT
    Jan 25 at 17:40











  • meanwhile you receive good answer :-). btw, your link in question is broken.

    – Zarko
    Jan 25 at 19:28











  • Thanks Zarko! I have fixed the link. :-)

    – PatrickT
    Jan 25 at 20:24
















2















This is a follow-up on this question. With pgfplotstable, I would like to create a style to highlight an entire row and/or column. Zarko's answer at the linked question shows how to bolden an entire row. It seemed pretty straightforward to extend that approach to an entire column... except that if I bolden rows and columns, the intersecting cells are "un-bolden". Help.



MWE:



    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
advancecount0 by1
ifnumcount0=#1
pgfkeysalso{@cell content/.add={$bf}{$}}%
fi
},
},
}

% Highlight entire column
pgfplotstableset{%
highlightcol/.style={
postproc cell content/.append code={
count0=pgfplotstablecol
advancecount0 by1
ifnumcount0=#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}


enter image description here










share|improve this question

























  • @Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

    – PatrickT
    Jan 25 at 17:40











  • meanwhile you receive good answer :-). btw, your link in question is broken.

    – Zarko
    Jan 25 at 19:28











  • Thanks Zarko! I have fixed the link. :-)

    – PatrickT
    Jan 25 at 20:24














2












2








2








This is a follow-up on this question. With pgfplotstable, I would like to create a style to highlight an entire row and/or column. Zarko's answer at the linked question shows how to bolden an entire row. It seemed pretty straightforward to extend that approach to an entire column... except that if I bolden rows and columns, the intersecting cells are "un-bolden". Help.



MWE:



    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
advancecount0 by1
ifnumcount0=#1
pgfkeysalso{@cell content/.add={$bf}{$}}%
fi
},
},
}

% Highlight entire column
pgfplotstableset{%
highlightcol/.style={
postproc cell content/.append code={
count0=pgfplotstablecol
advancecount0 by1
ifnumcount0=#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}


enter image description here










share|improve this question
















This is a follow-up on this question. With pgfplotstable, I would like to create a style to highlight an entire row and/or column. Zarko's answer at the linked question shows how to bolden an entire row. It seemed pretty straightforward to extend that approach to an entire column... except that if I bolden rows and columns, the intersecting cells are "un-bolden". Help.



MWE:



    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
advancecount0 by1
ifnumcount0=#1
pgfkeysalso{@cell content/.add={$bf}{$}}%
fi
},
},
}

% Highlight entire column
pgfplotstableset{%
highlightcol/.style={
postproc cell content/.append code={
count0=pgfplotstablecol
advancecount0 by1
ifnumcount0=#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}


enter image description here







pgfplotstable pgfmath






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 25 at 20:23







PatrickT

















asked Jan 25 at 17:38









PatrickTPatrickT

1,07221123




1,07221123













  • @Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

    – PatrickT
    Jan 25 at 17:40











  • meanwhile you receive good answer :-). btw, your link in question is broken.

    – Zarko
    Jan 25 at 19:28











  • Thanks Zarko! I have fixed the link. :-)

    – PatrickT
    Jan 25 at 20:24



















  • @Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

    – PatrickT
    Jan 25 at 17:40











  • meanwhile you receive good answer :-). btw, your link in question is broken.

    – Zarko
    Jan 25 at 19:28











  • Thanks Zarko! I have fixed the link. :-)

    – PatrickT
    Jan 25 at 20:24

















@Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

– PatrickT
Jan 25 at 17:40





@Zarko, you may be interested in this. Your template was excellent, thanks. tex.stackexchange.com/questions/286384

– PatrickT
Jan 25 at 17:40













meanwhile you receive good answer :-). btw, your link in question is broken.

– Zarko
Jan 25 at 19:28





meanwhile you receive good answer :-). btw, your link in question is broken.

– Zarko
Jan 25 at 19:28













Thanks Zarko! I have fixed the link. :-)

– PatrickT
Jan 25 at 20:24





Thanks Zarko! I have fixed the link. :-)

– PatrickT
Jan 25 at 20:24










1 Answer
1






active

oldest

votes


















3














Like this? (EDIT: fixed spaces, big thanks to @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%
advancecount0 by1%
ifnumcount0=#1%
pgfkeysalso{@cell content/.add={ifmmodeelseboldmathfi$}{$}}%
fi%
},
},
}

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

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


enter image description here






share|improve this answer





















  • 2





    boldmath! brilliant, thanks marmot!

    – PatrickT
    Jan 25 at 17:47








  • 2





    Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

    – PatrickT
    Jan 25 at 18:11








  • 2





    @PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

    – marmot
    Jan 25 at 18:15






  • 2





    changed it to boldmathbfseries and it works too. Thanks again!

    – PatrickT
    Jan 25 at 18:17








  • 2





    I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

    – PatrickT
    Jan 25 at 18:38













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471871%2fpgfplotstable-highlight-entire-rows-and-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Like this? (EDIT: fixed spaces, big thanks to @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%
advancecount0 by1%
ifnumcount0=#1%
pgfkeysalso{@cell content/.add={ifmmodeelseboldmathfi$}{$}}%
fi%
},
},
}

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

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


enter image description here






share|improve this answer





















  • 2





    boldmath! brilliant, thanks marmot!

    – PatrickT
    Jan 25 at 17:47








  • 2





    Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

    – PatrickT
    Jan 25 at 18:11








  • 2





    @PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

    – marmot
    Jan 25 at 18:15






  • 2





    changed it to boldmathbfseries and it works too. Thanks again!

    – PatrickT
    Jan 25 at 18:17








  • 2





    I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

    – PatrickT
    Jan 25 at 18:38


















3














Like this? (EDIT: fixed spaces, big thanks to @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%
advancecount0 by1%
ifnumcount0=#1%
pgfkeysalso{@cell content/.add={ifmmodeelseboldmathfi$}{$}}%
fi%
},
},
}

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

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


enter image description here






share|improve this answer





















  • 2





    boldmath! brilliant, thanks marmot!

    – PatrickT
    Jan 25 at 17:47








  • 2





    Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

    – PatrickT
    Jan 25 at 18:11








  • 2





    @PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

    – marmot
    Jan 25 at 18:15






  • 2





    changed it to boldmathbfseries and it works too. Thanks again!

    – PatrickT
    Jan 25 at 18:17








  • 2





    I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

    – PatrickT
    Jan 25 at 18:38
















3












3








3







Like this? (EDIT: fixed spaces, big thanks to @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%
advancecount0 by1%
ifnumcount0=#1%
pgfkeysalso{@cell content/.add={ifmmodeelseboldmathfi$}{$}}%
fi%
},
},
}

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

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


enter image description here






share|improve this answer















Like this? (EDIT: fixed spaces, big thanks to @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%
advancecount0 by1%
ifnumcount0=#1%
pgfkeysalso{@cell content/.add={ifmmodeelseboldmathfi$}{$}}%
fi%
},
},
}

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

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


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 25 at 18:50

























answered Jan 25 at 17:44









marmotmarmot

96.6k4111213




96.6k4111213








  • 2





    boldmath! brilliant, thanks marmot!

    – PatrickT
    Jan 25 at 17:47








  • 2





    Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

    – PatrickT
    Jan 25 at 18:11








  • 2





    @PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

    – marmot
    Jan 25 at 18:15






  • 2





    changed it to boldmathbfseries and it works too. Thanks again!

    – PatrickT
    Jan 25 at 18:17








  • 2





    I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

    – PatrickT
    Jan 25 at 18:38
















  • 2





    boldmath! brilliant, thanks marmot!

    – PatrickT
    Jan 25 at 17:47








  • 2





    Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

    – PatrickT
    Jan 25 at 18:11








  • 2





    @PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

    – marmot
    Jan 25 at 18:15






  • 2





    changed it to boldmathbfseries and it works too. Thanks again!

    – PatrickT
    Jan 25 at 18:17








  • 2





    I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

    – PatrickT
    Jan 25 at 18:38










2




2





boldmath! brilliant, thanks marmot!

– PatrickT
Jan 25 at 17:47







boldmath! brilliant, thanks marmot!

– PatrickT
Jan 25 at 17:47






2




2





Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

– PatrickT
Jan 25 at 18:11







Or maybe it was ifmmode! P.S. I added bf after boldmath to make it work in my use case. My MWE was a little too easy I guess.

– PatrickT
Jan 25 at 18:11






2




2





@PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

– marmot
Jan 25 at 18:15





@PatrickT It is sort of both, I think. The issue is that one should not use bf, but rather bfseries or boldmath. And because of nesting you had "double math mode" at the intersection of the special row with the special column. It seems like pgfplotstable takes care of this but not of the the bf statement in the desired way.

– marmot
Jan 25 at 18:15




2




2





changed it to boldmathbfseries and it works too. Thanks again!

– PatrickT
Jan 25 at 18:17







changed it to boldmathbfseries and it works too. Thanks again!

– PatrickT
Jan 25 at 18:17






2




2





I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

– PatrickT
Jan 25 at 18:38







I noticed the code was adding a lot of extra space (especially if used repeatedly). To fix this, I added a percentage sign at the end of each of the lines that start with pgfkeysalso{@cell content/.add=

– PatrickT
Jan 25 at 18:38




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471871%2fpgfplotstable-highlight-entire-rows-and-columns%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents