Changing the font in every second line of the table












4















I've already found solutions here that work over rowfont{} but not automatically adjust by even and odd number of lines.



I think about a case function it would work well for the first lines and then for the next. Unfortunately I don't understand the syntax and possibilities in LaTeX. Could someone please give me a solution for the problem



documentclass{article}
usepackage{array}% http://ctan.org/pkg/array
usepackage[table]{xcolor}
makeatletter
g@addto@macro{endtabular}{rowfont{}}% Clear row font
makeatother
newcommand{rowfonttype}{}% Current row font
newcommand{rowfont}{% Set current row font
gdefrowfonttype{color{white}}%
}
newcolumntype{L}{>{rowfonttype}l}

rowcolors{1}{blue}{orange}

begin{document}
begin{tabular}{LL}
rowfont
textbf{Hello}& textbf{World} \
textcolor{Black}{Foo} & textcolor{Black}{Bar} \
Hello & World
end{tabular}
end{document}









share|improve this question





























    4















    I've already found solutions here that work over rowfont{} but not automatically adjust by even and odd number of lines.



    I think about a case function it would work well for the first lines and then for the next. Unfortunately I don't understand the syntax and possibilities in LaTeX. Could someone please give me a solution for the problem



    documentclass{article}
    usepackage{array}% http://ctan.org/pkg/array
    usepackage[table]{xcolor}
    makeatletter
    g@addto@macro{endtabular}{rowfont{}}% Clear row font
    makeatother
    newcommand{rowfonttype}{}% Current row font
    newcommand{rowfont}{% Set current row font
    gdefrowfonttype{color{white}}%
    }
    newcolumntype{L}{>{rowfonttype}l}

    rowcolors{1}{blue}{orange}

    begin{document}
    begin{tabular}{LL}
    rowfont
    textbf{Hello}& textbf{World} \
    textcolor{Black}{Foo} & textcolor{Black}{Bar} \
    Hello & World
    end{tabular}
    end{document}









    share|improve this question



























      4












      4








      4








      I've already found solutions here that work over rowfont{} but not automatically adjust by even and odd number of lines.



      I think about a case function it would work well for the first lines and then for the next. Unfortunately I don't understand the syntax and possibilities in LaTeX. Could someone please give me a solution for the problem



      documentclass{article}
      usepackage{array}% http://ctan.org/pkg/array
      usepackage[table]{xcolor}
      makeatletter
      g@addto@macro{endtabular}{rowfont{}}% Clear row font
      makeatother
      newcommand{rowfonttype}{}% Current row font
      newcommand{rowfont}{% Set current row font
      gdefrowfonttype{color{white}}%
      }
      newcolumntype{L}{>{rowfonttype}l}

      rowcolors{1}{blue}{orange}

      begin{document}
      begin{tabular}{LL}
      rowfont
      textbf{Hello}& textbf{World} \
      textcolor{Black}{Foo} & textcolor{Black}{Bar} \
      Hello & World
      end{tabular}
      end{document}









      share|improve this question
















      I've already found solutions here that work over rowfont{} but not automatically adjust by even and odd number of lines.



      I think about a case function it would work well for the first lines and then for the next. Unfortunately I don't understand the syntax and possibilities in LaTeX. Could someone please give me a solution for the problem



      documentclass{article}
      usepackage{array}% http://ctan.org/pkg/array
      usepackage[table]{xcolor}
      makeatletter
      g@addto@macro{endtabular}{rowfont{}}% Clear row font
      makeatother
      newcommand{rowfonttype}{}% Current row font
      newcommand{rowfont}{% Set current row font
      gdefrowfonttype{color{white}}%
      }
      newcolumntype{L}{>{rowfonttype}l}

      rowcolors{1}{blue}{orange}

      begin{document}
      begin{tabular}{LL}
      rowfont
      textbf{Hello}& textbf{World} \
      textcolor{Black}{Foo} & textcolor{Black}{Bar} \
      Hello & World
      end{tabular}
      end{document}






      tables fonts formatting automation rowcolor






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 27 at 2:57









      JouleV

      2,499628




      2,499628










      asked Jan 27 at 2:54









      KaiKai

      211




      211






















          1 Answer
          1






          active

          oldest

          votes


















          2














          I think you can achieve your needs easily with a TikZ matrix.



          The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{matrix}

          begin{document}
          begin{tikzpicture}
          matrix [
          matrix of nodes,
          nodes in empty cells,
          column sep=-pgflinewidth,% if you don't want a visible separation between columns
          column 1/.style={
          nodes={text width=3em},%put the width you prefer here
          },
          column 2/.style={
          nodes={text width=4em},%put the width you prefer here
          },
          every odd row/.style={
          nodes={fill=blue, text=white},
          },
          every even row/.style={
          nodes={fill=orange},
          },
          every node/.style={
          font=bfseries,
          text height=1.75ex,
          text depth=.25ex,
          align=left
          },
          ] {
          Hello & World \
          Foo & Bar \
          Hello & World\
          };
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer
























          • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

            – manooooh
            Jan 27 at 9:55











          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%2f472052%2fchanging-the-font-in-every-second-line-of-the-table%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









          2














          I think you can achieve your needs easily with a TikZ matrix.



          The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{matrix}

          begin{document}
          begin{tikzpicture}
          matrix [
          matrix of nodes,
          nodes in empty cells,
          column sep=-pgflinewidth,% if you don't want a visible separation between columns
          column 1/.style={
          nodes={text width=3em},%put the width you prefer here
          },
          column 2/.style={
          nodes={text width=4em},%put the width you prefer here
          },
          every odd row/.style={
          nodes={fill=blue, text=white},
          },
          every even row/.style={
          nodes={fill=orange},
          },
          every node/.style={
          font=bfseries,
          text height=1.75ex,
          text depth=.25ex,
          align=left
          },
          ] {
          Hello & World \
          Foo & Bar \
          Hello & World\
          };
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer
























          • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

            – manooooh
            Jan 27 at 9:55
















          2














          I think you can achieve your needs easily with a TikZ matrix.



          The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{matrix}

          begin{document}
          begin{tikzpicture}
          matrix [
          matrix of nodes,
          nodes in empty cells,
          column sep=-pgflinewidth,% if you don't want a visible separation between columns
          column 1/.style={
          nodes={text width=3em},%put the width you prefer here
          },
          column 2/.style={
          nodes={text width=4em},%put the width you prefer here
          },
          every odd row/.style={
          nodes={fill=blue, text=white},
          },
          every even row/.style={
          nodes={fill=orange},
          },
          every node/.style={
          font=bfseries,
          text height=1.75ex,
          text depth=.25ex,
          align=left
          },
          ] {
          Hello & World \
          Foo & Bar \
          Hello & World\
          };
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer
























          • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

            – manooooh
            Jan 27 at 9:55














          2












          2








          2







          I think you can achieve your needs easily with a TikZ matrix.



          The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{matrix}

          begin{document}
          begin{tikzpicture}
          matrix [
          matrix of nodes,
          nodes in empty cells,
          column sep=-pgflinewidth,% if you don't want a visible separation between columns
          column 1/.style={
          nodes={text width=3em},%put the width you prefer here
          },
          column 2/.style={
          nodes={text width=4em},%put the width you prefer here
          },
          every odd row/.style={
          nodes={fill=blue, text=white},
          },
          every even row/.style={
          nodes={fill=orange},
          },
          every node/.style={
          font=bfseries,
          text height=1.75ex,
          text depth=.25ex,
          align=left
          },
          ] {
          Hello & World \
          Foo & Bar \
          Hello & World\
          };
          end{tikzpicture}
          end{document}


          enter image description here






          share|improve this answer













          I think you can achieve your needs easily with a TikZ matrix.



          The options every odd row and every even row allow you to set a style for even and odd rows without complicated code.



          documentclass{article}
          usepackage{tikz}
          usetikzlibrary{matrix}

          begin{document}
          begin{tikzpicture}
          matrix [
          matrix of nodes,
          nodes in empty cells,
          column sep=-pgflinewidth,% if you don't want a visible separation between columns
          column 1/.style={
          nodes={text width=3em},%put the width you prefer here
          },
          column 2/.style={
          nodes={text width=4em},%put the width you prefer here
          },
          every odd row/.style={
          nodes={fill=blue, text=white},
          },
          every even row/.style={
          nodes={fill=orange},
          },
          every node/.style={
          font=bfseries,
          text height=1.75ex,
          text depth=.25ex,
          align=left
          },
          ] {
          Hello & World \
          Foo & Bar \
          Hello & World\
          };
          end{tikzpicture}
          end{document}


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 27 at 7:59









          CarLaTeXCarLaTeX

          31k449129




          31k449129













          • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

            – manooooh
            Jan 27 at 9:55



















          • TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

            – manooooh
            Jan 27 at 9:55

















          TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

          – manooooh
          Jan 27 at 9:55





          TikZ allows us to do a lot of crazy things - thank you for share every odd/even row!!

          – manooooh
          Jan 27 at 9:55


















          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%2f472052%2fchanging-the-font-in-every-second-line-of-the-table%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