longtable with pgfplotstable - adding predefined rows and breaking manually











up vote
3
down vote

favorite
1












Based on this link pgfplotstable; longtable with caption and repeating header



I wrote this MWE:



documentclass{article}
usepackage{longtable}
usepackage{booktabs}
usepackage{multirow}
usepackage{pgfplotstable}
%%% Code from Dr. Christian ------ for not using headers.----------------------
pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
% upcoming releases offer this more convenient option:
pgfplotstableset{
empty header/.style={
every head row/.style={output empty row},
}
}
}{
% versions up to and including 1.5.1 need this:
pgfplotstableset{
empty header/.style={
typeset cell/.append code={%
ifnumpgfplotstablerow=-1 %
pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
fi
}
}
}
}
%%%-----------------------------------------------
begin{document}


pgfplotstabletypeset[
empty header,
begin table=begin{longtable},
end table=end{longtable},
col sep=semicolon, % space|tab|comma|semicolon|colon|braces|&|ampersand
/pgf/number format/precision=0, % precision
/pgf/number format/fixed, % format number
/pgf/number format/fixed zerofill,
/pgf/number format/set decimal separator = {,}, %decimal separator
/pgf/number format/1000 sep = {.},
% % % % % % % % % % % % % % % % % % % % % %
every first row/.append style={
% output empty row,
before row={%
caption{Population forecasting - Santo Antonio}%
label{tab:projpopagua}\
toprule
multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
%
&
multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
multicolumn{1}{p{2.0cm}}{bf Geometric} &
multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
midrule
%
endfirsthead
%
caption{Population forecasting - Santo Antonio}\
%
toprule
multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
%
&
multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
multicolumn{1}{p{2.0cm}}{bf Geometric} &
multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
midrule
%
endhead
%
midrule
multicolumn{5}{r}{textit{Continued on next page}} \ bottomrule
endfoot
%
bottomrule
endlastfoot
}},
% every last row/.append style = {after row={%
% %
% }}},
% % % % % % % % % % % % % % % %
every row no 0/.style = {before row = bf Immediate future\cmidrule{1-1}},
every row no 3/.style = {before row = bf Short term\cmidrule{1-1}},
every row no 8/.style = {before row = bf Mid-term\cmidrule{1-1}},
every row no 12/.style = {before row = bf Long term\cmidrule{1-1}},
% % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % % % % % % % %
display columns/1/.style={fixed},
display columns/2/.style={fixed},
display columns/3/.style={fixed},
display columns/4/.style={fixed},
display columns/5/.style={fixed},
]%
{%
2016;44030;44126;45049;45307
2017;44250;44367;45507;45842
2018;44471;44610;45986;46414
2019;44691;44853;46489;47025
2020;44912;45098;47015;47678
2021;45132;45345;47566;48379
2022;45352;45592;48144;49131
2023;45573;45842;48749;49940
2024;45793;46092;49382;50812
2025;46014;46344;50046;51753
2026;46234;46597;50741;52772
2027;46455;46852;51470;53876
2028;46675;47107;52233;55077
2029;46896;47365;53032;56387
2030;47116;47624;53869;57820
2031;47336;47884;54747;59391
2032;47557;48145;55665;61123
2033;47777;48408;56628;63037
2034;47998;48673;57636;65163
2035;48218;48939;58692;67537
2036;48439;49206;59799;70201
}
end{document}


But the result is:



enter image description here



Is possible to break line arbitrarily?



How can I improve the code to obtain something like this:



enter image description here










share|improve this question




























    up vote
    3
    down vote

    favorite
    1












    Based on this link pgfplotstable; longtable with caption and repeating header



    I wrote this MWE:



    documentclass{article}
    usepackage{longtable}
    usepackage{booktabs}
    usepackage{multirow}
    usepackage{pgfplotstable}
    %%% Code from Dr. Christian ------ for not using headers.----------------------
    pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
    % upcoming releases offer this more convenient option:
    pgfplotstableset{
    empty header/.style={
    every head row/.style={output empty row},
    }
    }
    }{
    % versions up to and including 1.5.1 need this:
    pgfplotstableset{
    empty header/.style={
    typeset cell/.append code={%
    ifnumpgfplotstablerow=-1 %
    pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
    fi
    }
    }
    }
    }
    %%%-----------------------------------------------
    begin{document}


    pgfplotstabletypeset[
    empty header,
    begin table=begin{longtable},
    end table=end{longtable},
    col sep=semicolon, % space|tab|comma|semicolon|colon|braces|&|ampersand
    /pgf/number format/precision=0, % precision
    /pgf/number format/fixed, % format number
    /pgf/number format/fixed zerofill,
    /pgf/number format/set decimal separator = {,}, %decimal separator
    /pgf/number format/1000 sep = {.},
    % % % % % % % % % % % % % % % % % % % % % %
    every first row/.append style={
    % output empty row,
    before row={%
    caption{Population forecasting - Santo Antonio}%
    label{tab:projpopagua}\
    toprule
    multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
    %
    &
    multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
    multicolumn{1}{p{2.0cm}}{bf Geometric} &
    multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
    multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
    midrule
    %
    endfirsthead
    %
    caption{Population forecasting - Santo Antonio}\
    %
    toprule
    multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
    %
    &
    multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
    multicolumn{1}{p{2.0cm}}{bf Geometric} &
    multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
    multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
    midrule
    %
    endhead
    %
    midrule
    multicolumn{5}{r}{textit{Continued on next page}} \ bottomrule
    endfoot
    %
    bottomrule
    endlastfoot
    }},
    % every last row/.append style = {after row={%
    % %
    % }}},
    % % % % % % % % % % % % % % % %
    every row no 0/.style = {before row = bf Immediate future\cmidrule{1-1}},
    every row no 3/.style = {before row = bf Short term\cmidrule{1-1}},
    every row no 8/.style = {before row = bf Mid-term\cmidrule{1-1}},
    every row no 12/.style = {before row = bf Long term\cmidrule{1-1}},
    % % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % % % % % % % %
    display columns/1/.style={fixed},
    display columns/2/.style={fixed},
    display columns/3/.style={fixed},
    display columns/4/.style={fixed},
    display columns/5/.style={fixed},
    ]%
    {%
    2016;44030;44126;45049;45307
    2017;44250;44367;45507;45842
    2018;44471;44610;45986;46414
    2019;44691;44853;46489;47025
    2020;44912;45098;47015;47678
    2021;45132;45345;47566;48379
    2022;45352;45592;48144;49131
    2023;45573;45842;48749;49940
    2024;45793;46092;49382;50812
    2025;46014;46344;50046;51753
    2026;46234;46597;50741;52772
    2027;46455;46852;51470;53876
    2028;46675;47107;52233;55077
    2029;46896;47365;53032;56387
    2030;47116;47624;53869;57820
    2031;47336;47884;54747;59391
    2032;47557;48145;55665;61123
    2033;47777;48408;56628;63037
    2034;47998;48673;57636;65163
    2035;48218;48939;58692;67537
    2036;48439;49206;59799;70201
    }
    end{document}


    But the result is:



    enter image description here



    Is possible to break line arbitrarily?



    How can I improve the code to obtain something like this:



    enter image description here










    share|improve this question


























      up vote
      3
      down vote

      favorite
      1









      up vote
      3
      down vote

      favorite
      1






      1





      Based on this link pgfplotstable; longtable with caption and repeating header



      I wrote this MWE:



      documentclass{article}
      usepackage{longtable}
      usepackage{booktabs}
      usepackage{multirow}
      usepackage{pgfplotstable}
      %%% Code from Dr. Christian ------ for not using headers.----------------------
      pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
      % upcoming releases offer this more convenient option:
      pgfplotstableset{
      empty header/.style={
      every head row/.style={output empty row},
      }
      }
      }{
      % versions up to and including 1.5.1 need this:
      pgfplotstableset{
      empty header/.style={
      typeset cell/.append code={%
      ifnumpgfplotstablerow=-1 %
      pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
      fi
      }
      }
      }
      }
      %%%-----------------------------------------------
      begin{document}


      pgfplotstabletypeset[
      empty header,
      begin table=begin{longtable},
      end table=end{longtable},
      col sep=semicolon, % space|tab|comma|semicolon|colon|braces|&|ampersand
      /pgf/number format/precision=0, % precision
      /pgf/number format/fixed, % format number
      /pgf/number format/fixed zerofill,
      /pgf/number format/set decimal separator = {,}, %decimal separator
      /pgf/number format/1000 sep = {.},
      % % % % % % % % % % % % % % % % % % % % % %
      every first row/.append style={
      % output empty row,
      before row={%
      caption{Population forecasting - Santo Antonio}%
      label{tab:projpopagua}\
      toprule
      multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
      %
      &
      multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
      multicolumn{1}{p{2.0cm}}{bf Geometric} &
      multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
      multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
      midrule
      %
      endfirsthead
      %
      caption{Population forecasting - Santo Antonio}\
      %
      toprule
      multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
      %
      &
      multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
      multicolumn{1}{p{2.0cm}}{bf Geometric} &
      multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
      multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
      midrule
      %
      endhead
      %
      midrule
      multicolumn{5}{r}{textit{Continued on next page}} \ bottomrule
      endfoot
      %
      bottomrule
      endlastfoot
      }},
      % every last row/.append style = {after row={%
      % %
      % }}},
      % % % % % % % % % % % % % % % %
      every row no 0/.style = {before row = bf Immediate future\cmidrule{1-1}},
      every row no 3/.style = {before row = bf Short term\cmidrule{1-1}},
      every row no 8/.style = {before row = bf Mid-term\cmidrule{1-1}},
      every row no 12/.style = {before row = bf Long term\cmidrule{1-1}},
      % % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % % % % % % % %
      display columns/1/.style={fixed},
      display columns/2/.style={fixed},
      display columns/3/.style={fixed},
      display columns/4/.style={fixed},
      display columns/5/.style={fixed},
      ]%
      {%
      2016;44030;44126;45049;45307
      2017;44250;44367;45507;45842
      2018;44471;44610;45986;46414
      2019;44691;44853;46489;47025
      2020;44912;45098;47015;47678
      2021;45132;45345;47566;48379
      2022;45352;45592;48144;49131
      2023;45573;45842;48749;49940
      2024;45793;46092;49382;50812
      2025;46014;46344;50046;51753
      2026;46234;46597;50741;52772
      2027;46455;46852;51470;53876
      2028;46675;47107;52233;55077
      2029;46896;47365;53032;56387
      2030;47116;47624;53869;57820
      2031;47336;47884;54747;59391
      2032;47557;48145;55665;61123
      2033;47777;48408;56628;63037
      2034;47998;48673;57636;65163
      2035;48218;48939;58692;67537
      2036;48439;49206;59799;70201
      }
      end{document}


      But the result is:



      enter image description here



      Is possible to break line arbitrarily?



      How can I improve the code to obtain something like this:



      enter image description here










      share|improve this question















      Based on this link pgfplotstable; longtable with caption and repeating header



      I wrote this MWE:



      documentclass{article}
      usepackage{longtable}
      usepackage{booktabs}
      usepackage{multirow}
      usepackage{pgfplotstable}
      %%% Code from Dr. Christian ------ for not using headers.----------------------
      pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
      % upcoming releases offer this more convenient option:
      pgfplotstableset{
      empty header/.style={
      every head row/.style={output empty row},
      }
      }
      }{
      % versions up to and including 1.5.1 need this:
      pgfplotstableset{
      empty header/.style={
      typeset cell/.append code={%
      ifnumpgfplotstablerow=-1 %
      pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
      fi
      }
      }
      }
      }
      %%%-----------------------------------------------
      begin{document}


      pgfplotstabletypeset[
      empty header,
      begin table=begin{longtable},
      end table=end{longtable},
      col sep=semicolon, % space|tab|comma|semicolon|colon|braces|&|ampersand
      /pgf/number format/precision=0, % precision
      /pgf/number format/fixed, % format number
      /pgf/number format/fixed zerofill,
      /pgf/number format/set decimal separator = {,}, %decimal separator
      /pgf/number format/1000 sep = {.},
      % % % % % % % % % % % % % % % % % % % % % %
      every first row/.append style={
      % output empty row,
      before row={%
      caption{Population forecasting - Santo Antonio}%
      label{tab:projpopagua}\
      toprule
      multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
      %
      &
      multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
      multicolumn{1}{p{2.0cm}}{bf Geometric} &
      multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
      multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
      midrule
      %
      endfirsthead
      %
      caption{Population forecasting - Santo Antonio}\
      %
      toprule
      multirow{2}{*}{bfseries Year} & multicolumn{4}{c}{bf Methods}\cmidrule{2-5}
      %
      &
      multicolumn{1}{p{2.0cm}}{bf Arithmetic} &
      multicolumn{1}{p{2.0cm}}{bf Geometric} &
      multicolumn{1}{p{2.0cm}}{bf Decreasing rate} &
      multicolumn{1}{p{2.5cm}}{bf Logistic growth} \
      midrule
      %
      endhead
      %
      midrule
      multicolumn{5}{r}{textit{Continued on next page}} \ bottomrule
      endfoot
      %
      bottomrule
      endlastfoot
      }},
      % every last row/.append style = {after row={%
      % %
      % }}},
      % % % % % % % % % % % % % % % %
      every row no 0/.style = {before row = bf Immediate future\cmidrule{1-1}},
      every row no 3/.style = {before row = bf Short term\cmidrule{1-1}},
      every row no 8/.style = {before row = bf Mid-term\cmidrule{1-1}},
      every row no 12/.style = {before row = bf Long term\cmidrule{1-1}},
      % % % % % % % % % % % % % % % % % %% % % % % % % % % % % % % % % % % % % % % %
      display columns/1/.style={fixed},
      display columns/2/.style={fixed},
      display columns/3/.style={fixed},
      display columns/4/.style={fixed},
      display columns/5/.style={fixed},
      ]%
      {%
      2016;44030;44126;45049;45307
      2017;44250;44367;45507;45842
      2018;44471;44610;45986;46414
      2019;44691;44853;46489;47025
      2020;44912;45098;47015;47678
      2021;45132;45345;47566;48379
      2022;45352;45592;48144;49131
      2023;45573;45842;48749;49940
      2024;45793;46092;49382;50812
      2025;46014;46344;50046;51753
      2026;46234;46597;50741;52772
      2027;46455;46852;51470;53876
      2028;46675;47107;52233;55077
      2029;46896;47365;53032;56387
      2030;47116;47624;53869;57820
      2031;47336;47884;54747;59391
      2032;47557;48145;55665;61123
      2033;47777;48408;56628;63037
      2034;47998;48673;57636;65163
      2035;48218;48939;58692;67537
      2036;48439;49206;59799;70201
      }
      end{document}


      But the result is:



      enter image description here



      Is possible to break line arbitrarily?



      How can I improve the code to obtain something like this:



      enter image description here







      longtable pgfplotstable






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 19:07

























      asked Apr 1 '16 at 19:01









      leonardo cesar

      320314




      320314



























          active

          oldest

          votes











          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',
          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%2f302015%2flongtable-with-pgfplotstable-adding-predefined-rows-and-breaking-manually%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f302015%2flongtable-with-pgfplotstable-adding-predefined-rows-and-breaking-manually%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?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

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