ConTeXt: xtables zebra stripe

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












4














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]
dorecurse4
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?










share|improve this question




























    4














    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]
    dorecurse4
    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?










    share|improve this question


























      4












      4








      4







      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]
      dorecurse4
      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?










      share|improve this question















      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]
      dorecurse4
      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 14 at 20:56

























      asked Dec 13 at 21:35









      Dave Jarvis

      4,48974080




      4,48974080




















          1 Answer
          1






          active

          oldest

          votes


















          7














          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]
          dorecurse9bTR expandedbTD 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 MPcolorgray ;
          stopuseMPgraphic

          defineoverlay
          [tablebackground]
          [ifoddcurrentxtablerow
          useMPgraphictablebackground%
          fi]

          starttext

          startxtable[background=tablebackground]
          dorecurse9startxrow expandedstartxcell Row recurselevel stopxcell stopxrow
          stopxtable

          stoptext


          To skip the table header:



          defineoverlay
          [tablebackground]
          [ifnumcurrentxtablerow>1
          ifoddcurrentxtablerowuseMPgraphictablebackgroundfi
          fi]


          To apply shading against even rows:



          startuseMPgraphic tablebackground
          fill OverlayBox withcolor MPcolorgray ;
          stopuseMPgraphic

          defineoverlay
          [tablebackground]
          [ifnumcurrentxtablerow>1
          ifoddcurrentxtablerow else
          useMPgraphictablebackground%
          fi
          fi]

          setupxtable[background=tablebackground]


          To apply the background against all tables in the document, use:



          setupxtable[background=tablebackground]





          share|improve this answer






















            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%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









            7














            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]
            dorecurse9bTR expandedbTD 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 MPcolorgray ;
            stopuseMPgraphic

            defineoverlay
            [tablebackground]
            [ifoddcurrentxtablerow
            useMPgraphictablebackground%
            fi]

            starttext

            startxtable[background=tablebackground]
            dorecurse9startxrow expandedstartxcell Row recurselevel stopxcell stopxrow
            stopxtable

            stoptext


            To skip the table header:



            defineoverlay
            [tablebackground]
            [ifnumcurrentxtablerow>1
            ifoddcurrentxtablerowuseMPgraphictablebackgroundfi
            fi]


            To apply shading against even rows:



            startuseMPgraphic tablebackground
            fill OverlayBox withcolor MPcolorgray ;
            stopuseMPgraphic

            defineoverlay
            [tablebackground]
            [ifnumcurrentxtablerow>1
            ifoddcurrentxtablerow else
            useMPgraphictablebackground%
            fi
            fi]

            setupxtable[background=tablebackground]


            To apply the background against all tables in the document, use:



            setupxtable[background=tablebackground]





            share|improve this answer



























              7














              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]
              dorecurse9bTR expandedbTD 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 MPcolorgray ;
              stopuseMPgraphic

              defineoverlay
              [tablebackground]
              [ifoddcurrentxtablerow
              useMPgraphictablebackground%
              fi]

              starttext

              startxtable[background=tablebackground]
              dorecurse9startxrow expandedstartxcell Row recurselevel stopxcell stopxrow
              stopxtable

              stoptext


              To skip the table header:



              defineoverlay
              [tablebackground]
              [ifnumcurrentxtablerow>1
              ifoddcurrentxtablerowuseMPgraphictablebackgroundfi
              fi]


              To apply shading against even rows:



              startuseMPgraphic tablebackground
              fill OverlayBox withcolor MPcolorgray ;
              stopuseMPgraphic

              defineoverlay
              [tablebackground]
              [ifnumcurrentxtablerow>1
              ifoddcurrentxtablerow else
              useMPgraphictablebackground%
              fi
              fi]

              setupxtable[background=tablebackground]


              To apply the background against all tables in the document, use:



              setupxtable[background=tablebackground]





              share|improve this answer

























                7












                7








                7






                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]
                dorecurse9bTR expandedbTD 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 MPcolorgray ;
                stopuseMPgraphic

                defineoverlay
                [tablebackground]
                [ifoddcurrentxtablerow
                useMPgraphictablebackground%
                fi]

                starttext

                startxtable[background=tablebackground]
                dorecurse9startxrow expandedstartxcell Row recurselevel stopxcell stopxrow
                stopxtable

                stoptext


                To skip the table header:



                defineoverlay
                [tablebackground]
                [ifnumcurrentxtablerow>1
                ifoddcurrentxtablerowuseMPgraphictablebackgroundfi
                fi]


                To apply shading against even rows:



                startuseMPgraphic tablebackground
                fill OverlayBox withcolor MPcolorgray ;
                stopuseMPgraphic

                defineoverlay
                [tablebackground]
                [ifnumcurrentxtablerow>1
                ifoddcurrentxtablerow else
                useMPgraphictablebackground%
                fi
                fi]

                setupxtable[background=tablebackground]


                To apply the background against all tables in the document, use:



                setupxtable[background=tablebackground]





                share|improve this answer














                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]
                dorecurse9bTR expandedbTD 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 MPcolorgray ;
                stopuseMPgraphic

                defineoverlay
                [tablebackground]
                [ifoddcurrentxtablerow
                useMPgraphictablebackground%
                fi]

                starttext

                startxtable[background=tablebackground]
                dorecurse9startxrow expandedstartxcell Row recurselevel stopxcell stopxrow
                stopxtable

                stoptext


                To skip the table header:



                defineoverlay
                [tablebackground]
                [ifnumcurrentxtablerow>1
                ifoddcurrentxtablerowuseMPgraphictablebackgroundfi
                fi]


                To apply shading against even rows:



                startuseMPgraphic tablebackground
                fill OverlayBox withcolor MPcolorgray ;
                stopuseMPgraphic

                defineoverlay
                [tablebackground]
                [ifnumcurrentxtablerow>1
                ifoddcurrentxtablerow else
                useMPgraphictablebackground%
                fi
                fi]

                setupxtable[background=tablebackground]


                To apply the background against all tables in the document, use:



                setupxtable[background=tablebackground]






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 14 at 21:05

























                answered Dec 13 at 21:55









                Wolfgang Schuster

                4,9261711




                4,9261711



























                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f464770%2fcontext-xtables-zebra-stripe%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 check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?