Skip to main content
added 3 characters in body
Source Link
percusse
  • 159.7k
  • 15
  • 344
  • 577
\documentclass{article} \usepackage{pgfplotstable,multirow,booktabs} \pgfplotstableset{toughtable/.style={ every head row/.style={before row={\toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{#1}}} &\multicolumn{2}{c}{Type} &\multicolumn{2}{c}{Size} &\multirow{2}{*}{All}\ \\  }, after row=\midrule }, every last row/.style={after row=\bottomrule}, create on use/myfirstcol/.style ={create col/set list={Good,Ugly,,,Bad,\textbf{TOTAL}}},%A dummy column create on use/mysecondcol/.style={create col/set list={,Cow,Goat,Horse,}},%A dummy column create on use/summationcol/.style={ create col/expr={\thisrowno{0}+\thisrowno{1}-\thisrowno{2}-\thisrowno{3}==0?\thisrowno{0}+\thisrowno{1}:0} }, columns={myfirstcol,mysecondcol,[index]0,[index]1,[index]2,[index]3,summationcol}, columns/myfirstcol/.style={string type,column name=, assign cell content/.code={% \ifnum\pgfplotstablerow=1\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{3}{*}{Ugly}}\fi } }, columns/mysecondcol/.style={string type,column name=}, columns/summationcol/.style={string type,column name=, assign cell content/.code={ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}==0?int(1):int(0)} \ifnum\pgfmathresult=1\relax \pgfkeyssetvalue{/pgfplots/table/@cell content}{Chicken Run!!}% \else \pgfmathparse{int(\pgfkeysvalueof{/pgfplots/table/@unprocessed cell content})} \edef\temp{\noexpand\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfmathresult}}\temp \fi } }, display columns/2/.style={column name=A}, display columns/3/.style={column name=B}, display columns/4/.style={column name=Big}, display columns/5/.style={column name=Small}, every row no 1/.style={before row=\hline,after row=\cmidrule{2-7}}, every row no 2/.style={after row=\cmidrule{2-7}}, every row no 3/.style={after row=\hline}, every row no 4/.style={after row=\hline}, } } \begin{document} \pgfplotstabletypeset[toughtable=NUMBERS]{ 1 4 2 3 7 1 3 4 1 2 0 3 2 1 3 0 12 1 6 7 } \end{document} 
\documentclass{article} \usepackage{pgfplotstable,multirow,booktabs} \pgfplotstableset{toughtable/.style={ every head row/.style={before row={\toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{#1}}} &\multicolumn{2}{c}{Type} &\multicolumn{2}{c}{Size} &\multirow{2}{*}{All}\  }, after row=\midrule }, every last row/.style={after row=\bottomrule}, create on use/myfirstcol/.style ={create col/set list={Good,Ugly,,,Bad,\textbf{TOTAL}}},%A dummy column create on use/mysecondcol/.style={create col/set list={,Cow,Goat,Horse,}},%A dummy column create on use/summationcol/.style={ create col/expr={\thisrowno{0}+\thisrowno{1}-\thisrowno{2}-\thisrowno{3}==0?\thisrowno{0}+\thisrowno{1}:0} }, columns={myfirstcol,mysecondcol,[index]0,[index]1,[index]2,[index]3,summationcol}, columns/myfirstcol/.style={string type,column name=, assign cell content/.code={% \ifnum\pgfplotstablerow=1\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{3}{*}{Ugly}}\fi } }, columns/mysecondcol/.style={string type,column name=}, columns/summationcol/.style={string type,column name=, assign cell content/.code={ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}==0?int(1):int(0)} \ifnum\pgfmathresult=1\relax \pgfkeyssetvalue{/pgfplots/table/@cell content}{Chicken Run!!}% \else \pgfmathparse{int(\pgfkeysvalueof{/pgfplots/table/@unprocessed cell content})} \edef\temp{\noexpand\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfmathresult}}\temp \fi } }, display columns/2/.style={column name=A}, display columns/3/.style={column name=B}, display columns/4/.style={column name=Big}, display columns/5/.style={column name=Small}, every row no 1/.style={before row=\hline,after row=\cmidrule{2-7}}, every row no 2/.style={after row=\cmidrule{2-7}}, every row no 3/.style={after row=\hline}, every row no 4/.style={after row=\hline}, } } \begin{document} \pgfplotstabletypeset[toughtable=NUMBERS]{ 1 4 2 3 7 1 3 4 1 2 0 3 2 1 3 0 12 1 6 7 } \end{document} 
\documentclass{article} \usepackage{pgfplotstable,multirow,booktabs} \pgfplotstableset{toughtable/.style={ every head row/.style={before row={\toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{#1}}} &\multicolumn{2}{c}{Type} &\multicolumn{2}{c}{Size} &\multirow{2}{*}{All}\\  }, after row=\midrule }, every last row/.style={after row=\bottomrule}, create on use/myfirstcol/.style ={create col/set list={Good,Ugly,,,Bad,\textbf{TOTAL}}},%A dummy column create on use/mysecondcol/.style={create col/set list={,Cow,Goat,Horse,}},%A dummy column create on use/summationcol/.style={ create col/expr={\thisrowno{0}+\thisrowno{1}-\thisrowno{2}-\thisrowno{3}==0?\thisrowno{0}+\thisrowno{1}:0} }, columns={myfirstcol,mysecondcol,[index]0,[index]1,[index]2,[index]3,summationcol}, columns/myfirstcol/.style={string type,column name=, assign cell content/.code={% \ifnum\pgfplotstablerow=1\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{3}{*}{Ugly}}\fi } }, columns/mysecondcol/.style={string type,column name=}, columns/summationcol/.style={string type,column name=, assign cell content/.code={ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}==0?int(1):int(0)} \ifnum\pgfmathresult=1\relax \pgfkeyssetvalue{/pgfplots/table/@cell content}{Chicken Run!!}% \else \pgfmathparse{int(\pgfkeysvalueof{/pgfplots/table/@unprocessed cell content})} \edef\temp{\noexpand\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfmathresult}}\temp \fi } }, display columns/2/.style={column name=A}, display columns/3/.style={column name=B}, display columns/4/.style={column name=Big}, display columns/5/.style={column name=Small}, every row no 1/.style={before row=\hline,after row=\cmidrule{2-7}}, every row no 2/.style={after row=\cmidrule{2-7}}, every row no 3/.style={after row=\hline}, every row no 4/.style={after row=\hline}, } } \begin{document} \pgfplotstabletypeset[toughtable=NUMBERS]{ 1 4 2 3 7 1 3 4 1 2 0 3 2 1 3 0 12 1 6 7 } \end{document} 
Source Link
percusse
  • 159.7k
  • 15
  • 344
  • 577

A half-baked pgfplotstable solution. The column sums are missing but sanity check on the sums of rows are implemented (gives the stupid error in the screenshot if there is a discrepancy). Also the upper left corner text is optional you can change it when entering the table. With this you don't need to enter your data in a tabular format.

\documentclass{article} \usepackage{pgfplotstable,multirow,booktabs} \pgfplotstableset{toughtable/.style={ every head row/.style={before row={\toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{#1}}} &\multicolumn{2}{c}{Type} &\multicolumn{2}{c}{Size} &\multirow{2}{*}{All}\ }, after row=\midrule }, every last row/.style={after row=\bottomrule}, create on use/myfirstcol/.style ={create col/set list={Good,Ugly,,,Bad,\textbf{TOTAL}}},%A dummy column create on use/mysecondcol/.style={create col/set list={,Cow,Goat,Horse,}},%A dummy column create on use/summationcol/.style={ create col/expr={\thisrowno{0}+\thisrowno{1}-\thisrowno{2}-\thisrowno{3}==0?\thisrowno{0}+\thisrowno{1}:0} }, columns={myfirstcol,mysecondcol,[index]0,[index]1,[index]2,[index]3,summationcol}, columns/myfirstcol/.style={string type,column name=, assign cell content/.code={% \ifnum\pgfplotstablerow=1\pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{3}{*}{Ugly}}\fi } }, columns/mysecondcol/.style={string type,column name=}, columns/summationcol/.style={string type,column name=, assign cell content/.code={ \pgfmathparse{\pgfkeysvalueof{/pgfplots/table/@preprocessed cell content}==0?int(1):int(0)} \ifnum\pgfmathresult=1\relax \pgfkeyssetvalue{/pgfplots/table/@cell content}{Chicken Run!!}% \else \pgfmathparse{int(\pgfkeysvalueof{/pgfplots/table/@unprocessed cell content})} \edef\temp{\noexpand\pgfkeyssetvalue{/pgfplots/table/@cell content}{\pgfmathresult}}\temp \fi } }, display columns/2/.style={column name=A}, display columns/3/.style={column name=B}, display columns/4/.style={column name=Big}, display columns/5/.style={column name=Small}, every row no 1/.style={before row=\hline,after row=\cmidrule{2-7}}, every row no 2/.style={after row=\cmidrule{2-7}}, every row no 3/.style={after row=\hline}, every row no 4/.style={after row=\hline}, } } \begin{document} \pgfplotstabletypeset[toughtable=NUMBERS]{ 1 4 2 3 7 1 3 4 1 2 0 3 2 1 3 0 12 1 6 7 } \end{document} 

enter image description here

I'll try to get the columns sum hopefully soon.