ConTeXt: xtables zebra stripe
Background
Set up zebra striping using extreme tables. The ConTeXt tables are generated by converting an ASCII Markdown table via pandoc.
Minimum Example
starttext
startplacetable
startxtable
startxtablehead[head]
startxrow
startxcell Item stopxcell
startxcell[align=left] Cost ($) stopxcell
startxcell[align=left] Description stopxcell
stopxrow
stopxtablehead
startxtablebody[body]
dorecurse{4}{
startxrow
startxcell Item stopxcell
startxcell[align=left] 100 stopxcell
startxcell[align=left] Cow text stopxcell
stopxrow
}
stopxtablebody
startxtablefoot[foot]
startxrow
startxcell {bf Total} stopxcell
startxcell[align=left] {bf 400} stopxcell
startxcell[align=left] stopxcell
stopxrow
stopxtablefoot
stopxtable
stopplacetable
stoptext
Problem
ConTeXt, which is rather consistent with its setup
macros, does not appear to define a setupxrow
or setupxcell
. I had anticipated something like:
definecolor[lime][r=0.75, g=1, b=0]
definecolor[transparentred][r=1,t=.5,a=1]
setupxrow[odd][background=lime]
setupxrow[even][background=transparentred]
This did not compile.
Question
Without using definextable
to create a custom xtable definition, how would you apply zebra striping so that every other non-header row has a coloured background?
color context backgrounds extreme-tables
add a comment |
Background
Set up zebra striping using extreme tables. The ConTeXt tables are generated by converting an ASCII Markdown table via pandoc.
Minimum Example
starttext
startplacetable
startxtable
startxtablehead[head]
startxrow
startxcell Item stopxcell
startxcell[align=left] Cost ($) stopxcell
startxcell[align=left] Description stopxcell
stopxrow
stopxtablehead
startxtablebody[body]
dorecurse{4}{
startxrow
startxcell Item stopxcell
startxcell[align=left] 100 stopxcell
startxcell[align=left] Cow text stopxcell
stopxrow
}
stopxtablebody
startxtablefoot[foot]
startxrow
startxcell {bf Total} stopxcell
startxcell[align=left] {bf 400} stopxcell
startxcell[align=left] stopxcell
stopxrow
stopxtablefoot
stopxtable
stopplacetable
stoptext
Problem
ConTeXt, which is rather consistent with its setup
macros, does not appear to define a setupxrow
or setupxcell
. I had anticipated something like:
definecolor[lime][r=0.75, g=1, b=0]
definecolor[transparentred][r=1,t=.5,a=1]
setupxrow[odd][background=lime]
setupxrow[even][background=transparentred]
This did not compile.
Question
Without using definextable
to create a custom xtable definition, how would you apply zebra striping so that every other non-header row has a coloured background?
color context backgrounds extreme-tables
add a comment |
Background
Set up zebra striping using extreme tables. The ConTeXt tables are generated by converting an ASCII Markdown table via pandoc.
Minimum Example
starttext
startplacetable
startxtable
startxtablehead[head]
startxrow
startxcell Item stopxcell
startxcell[align=left] Cost ($) stopxcell
startxcell[align=left] Description stopxcell
stopxrow
stopxtablehead
startxtablebody[body]
dorecurse{4}{
startxrow
startxcell Item stopxcell
startxcell[align=left] 100 stopxcell
startxcell[align=left] Cow text stopxcell
stopxrow
}
stopxtablebody
startxtablefoot[foot]
startxrow
startxcell {bf Total} stopxcell
startxcell[align=left] {bf 400} stopxcell
startxcell[align=left] stopxcell
stopxrow
stopxtablefoot
stopxtable
stopplacetable
stoptext
Problem
ConTeXt, which is rather consistent with its setup
macros, does not appear to define a setupxrow
or setupxcell
. I had anticipated something like:
definecolor[lime][r=0.75, g=1, b=0]
definecolor[transparentred][r=1,t=.5,a=1]
setupxrow[odd][background=lime]
setupxrow[even][background=transparentred]
This did not compile.
Question
Without using definextable
to create a custom xtable definition, how would you apply zebra striping so that every other non-header row has a coloured background?
color context backgrounds extreme-tables
Background
Set up zebra striping using extreme tables. The ConTeXt tables are generated by converting an ASCII Markdown table via pandoc.
Minimum Example
starttext
startplacetable
startxtable
startxtablehead[head]
startxrow
startxcell Item stopxcell
startxcell[align=left] Cost ($) stopxcell
startxcell[align=left] Description stopxcell
stopxrow
stopxtablehead
startxtablebody[body]
dorecurse{4}{
startxrow
startxcell Item stopxcell
startxcell[align=left] 100 stopxcell
startxcell[align=left] Cow text stopxcell
stopxrow
}
stopxtablebody
startxtablefoot[foot]
startxrow
startxcell {bf Total} stopxcell
startxcell[align=left] {bf 400} stopxcell
startxcell[align=left] stopxcell
stopxrow
stopxtablefoot
stopxtable
stopplacetable
stoptext
Problem
ConTeXt, which is rather consistent with its setup
macros, does not appear to define a setupxrow
or setupxcell
. I had anticipated something like:
definecolor[lime][r=0.75, g=1, b=0]
definecolor[transparentred][r=1,t=.5,a=1]
setupxrow[odd][background=lime]
setupxrow[even][background=transparentred]
This did not compile.
Question
Without using definextable
to create a custom xtable definition, how would you apply zebra striping so that every other non-header row has a coloured background?
color context backgrounds extreme-tables
color context backgrounds extreme-tables
edited Dec 14 '18 at 20:56
Dave Jarvis
asked Dec 13 '18 at 21:35
Dave JarvisDave Jarvis
4,53174082
4,53174082
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
With natural tables this would have been easy because the environment let you set different values for even and odd rows.
startsetups [tablebackground]
setupTABLE [row] [odd] [background=color,backgroundcolor=gray]
stopsetups
starttext
bTABLE[setups=tablebackground]
dorecurse{9}{bTR expanded{bTD Row recurselevel eTD} eTR}
eTABLE
stoptext
Extreme tables on the other hand don’t support this kind of setup and you have to use the overlay
mechanism to create your own backgrounds for the cells.
In the overlay setting you can check the value of the currentxtablerow
counter to apply a different command for odd and even rows.
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifoddcurrentxtablerow
useMPgraphic{tablebackground}%
fi]
starttext
startxtable[background=tablebackground]
dorecurse{9}{startxrow expanded{startxcell Row recurselevel stopxcell} stopxrow}
stopxtable
stoptext
To skip the table header:
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerowuseMPgraphic{tablebackground}fi
fi]
To apply shading against even rows:
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerow else
useMPgraphic{tablebackground}%
fi
fi]
setupxtable[background=tablebackground]
To apply the background against all tables in the document, use:
setupxtable[background=tablebackground]
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464770%2fcontext-xtables-zebra-stripe%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
With natural tables this would have been easy because the environment let you set different values for even and odd rows.
startsetups [tablebackground]
setupTABLE [row] [odd] [background=color,backgroundcolor=gray]
stopsetups
starttext
bTABLE[setups=tablebackground]
dorecurse{9}{bTR expanded{bTD Row recurselevel eTD} eTR}
eTABLE
stoptext
Extreme tables on the other hand don’t support this kind of setup and you have to use the overlay
mechanism to create your own backgrounds for the cells.
In the overlay setting you can check the value of the currentxtablerow
counter to apply a different command for odd and even rows.
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifoddcurrentxtablerow
useMPgraphic{tablebackground}%
fi]
starttext
startxtable[background=tablebackground]
dorecurse{9}{startxrow expanded{startxcell Row recurselevel stopxcell} stopxrow}
stopxtable
stoptext
To skip the table header:
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerowuseMPgraphic{tablebackground}fi
fi]
To apply shading against even rows:
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerow else
useMPgraphic{tablebackground}%
fi
fi]
setupxtable[background=tablebackground]
To apply the background against all tables in the document, use:
setupxtable[background=tablebackground]
add a comment |
With natural tables this would have been easy because the environment let you set different values for even and odd rows.
startsetups [tablebackground]
setupTABLE [row] [odd] [background=color,backgroundcolor=gray]
stopsetups
starttext
bTABLE[setups=tablebackground]
dorecurse{9}{bTR expanded{bTD Row recurselevel eTD} eTR}
eTABLE
stoptext
Extreme tables on the other hand don’t support this kind of setup and you have to use the overlay
mechanism to create your own backgrounds for the cells.
In the overlay setting you can check the value of the currentxtablerow
counter to apply a different command for odd and even rows.
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifoddcurrentxtablerow
useMPgraphic{tablebackground}%
fi]
starttext
startxtable[background=tablebackground]
dorecurse{9}{startxrow expanded{startxcell Row recurselevel stopxcell} stopxrow}
stopxtable
stoptext
To skip the table header:
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerowuseMPgraphic{tablebackground}fi
fi]
To apply shading against even rows:
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerow else
useMPgraphic{tablebackground}%
fi
fi]
setupxtable[background=tablebackground]
To apply the background against all tables in the document, use:
setupxtable[background=tablebackground]
add a comment |
With natural tables this would have been easy because the environment let you set different values for even and odd rows.
startsetups [tablebackground]
setupTABLE [row] [odd] [background=color,backgroundcolor=gray]
stopsetups
starttext
bTABLE[setups=tablebackground]
dorecurse{9}{bTR expanded{bTD Row recurselevel eTD} eTR}
eTABLE
stoptext
Extreme tables on the other hand don’t support this kind of setup and you have to use the overlay
mechanism to create your own backgrounds for the cells.
In the overlay setting you can check the value of the currentxtablerow
counter to apply a different command for odd and even rows.
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifoddcurrentxtablerow
useMPgraphic{tablebackground}%
fi]
starttext
startxtable[background=tablebackground]
dorecurse{9}{startxrow expanded{startxcell Row recurselevel stopxcell} stopxrow}
stopxtable
stoptext
To skip the table header:
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerowuseMPgraphic{tablebackground}fi
fi]
To apply shading against even rows:
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerow else
useMPgraphic{tablebackground}%
fi
fi]
setupxtable[background=tablebackground]
To apply the background against all tables in the document, use:
setupxtable[background=tablebackground]
With natural tables this would have been easy because the environment let you set different values for even and odd rows.
startsetups [tablebackground]
setupTABLE [row] [odd] [background=color,backgroundcolor=gray]
stopsetups
starttext
bTABLE[setups=tablebackground]
dorecurse{9}{bTR expanded{bTD Row recurselevel eTD} eTR}
eTABLE
stoptext
Extreme tables on the other hand don’t support this kind of setup and you have to use the overlay
mechanism to create your own backgrounds for the cells.
In the overlay setting you can check the value of the currentxtablerow
counter to apply a different command for odd and even rows.
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifoddcurrentxtablerow
useMPgraphic{tablebackground}%
fi]
starttext
startxtable[background=tablebackground]
dorecurse{9}{startxrow expanded{startxcell Row recurselevel stopxcell} stopxrow}
stopxtable
stoptext
To skip the table header:
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerowuseMPgraphic{tablebackground}fi
fi]
To apply shading against even rows:
startuseMPgraphic {tablebackground}
fill OverlayBox withcolor MPcolor{gray} ;
stopuseMPgraphic
defineoverlay
[tablebackground]
[ifnumcurrentxtablerow>1
ifoddcurrentxtablerow else
useMPgraphic{tablebackground}%
fi
fi]
setupxtable[background=tablebackground]
To apply the background against all tables in the document, use:
setupxtable[background=tablebackground]
edited Dec 14 '18 at 21:05
answered Dec 13 '18 at 21:55
Wolfgang SchusterWolfgang Schuster
5,5811711
5,5811711
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f464770%2fcontext-xtables-zebra-stripe%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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