5
\begin{spreadtab}{{tabular}{rrrr}}
\toprule
               & @A              & @B            & @C         \\
\midrule
        1     & 33 122   & 133/\Factor   & 156/\Factor \\
        2     & 66 112   & 135/\Factor   & 155/\Factor \\
        3     & 77 150   & 139/\Factor   & 158/\Factor \\
        4     & 55 145   & 135/\Factor   & 159/\Factor \\
        5     & 44 150   & 130/\Factor   & 200/\Factor \\
\bottomrule
\end{spreadtab}

I receive this error

FP Evaluation results in multiple values!

Is there a trick that i can use to insert multiple values ?

3
  • Can you please explain why do you want to have multiple values in one cell? A description of your goal could be useful. Jul 31 '12 at 6:14
  • i need to display feature numbers selected by feature selection algorithm on one column. and the amount of features can vary
    – user581544
    Jul 31 '12 at 6:19
  • Related Question: divide table cells by a certain amount. Jul 31 '12 at 8:30
5

I am not sure if this is what you need, but you can treat those values as text entries:

\documentclass{article}
\usepackage{numprint}
\usepackage{booktabs}
\usepackage{spreadtab}

\newcommand\Factor{105}

\begin{document}

\renewcommand\STprintnum[1]{\numprint{#1}}
\nprounddigits{3}
\begin{spreadtab}{{tabular}{rrrr}}
\toprule
               & @A              & @B            & @C         \\
\midrule
        1     & @33 122   & 133/\Factor   & 156/\Factor \\
        2     & @66 112   & 135/\Factor   & 155/\Factor \\
        3     & @77 150   & 139/\Factor   & 158/\Factor \\
        4     & @55 145   & 135/\Factor   & 159/\Factor \\
        5     & @44 150   & 130/\Factor   & 200/\Factor \\
\bottomrule
\end{spreadtab}

\end{document}

enter image description here

1

You can also adapt the solutions form divide table cells by a certain amount for this case. Here is the automated version which uses the r column type for the column where you don't want the factor applied and the R column type to apply the factor. The first table here uses {rrrr} and the second table uses {rrRR} columns.

enter image description here

Code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{collcell}
\usepackage{pgf}
\usepackage{etoolbox}
\usepackage{letltxmacro}

\newcommand{\Factor}{105}%
\newcommand{\FactorCell}[1]{%
    \iftoggle{DoneWithHeader}{%
        \pgfmathsetmacro{\ComputedValue}{#1/\Factor}%
        \pgfmathprintnumber[precision=3]{\ComputedValue}%
    }{%
        #1% Still working on header
    }%
}%
\newtoggle{DoneWithHeader}%
\togglefalse{DoneWithHeader}%
\newcommand*{\StartingHeader}{\global\togglefalse{DoneWithHeader}}%
\newcommand*{\DoneWithHeader}{\global\toggletrue{DoneWithHeader}}%

\LetLtxMacro\OldTopRule\toprule
\def\toprule{\StartingHeader\noexpand\OldTopRule}

\LetLtxMacro\OldMidRule\midrule
\def\midrule{\DoneWithHeader\noexpand\OldMidRule}

\newcolumntype{R}{>{\collectcell\FactorCell}r<{\endcollectcell}}

\begin{document}
\begin{tabular}{rrrr}
    \toprule
              & A     & B     & C \\
    \midrule
        1     & 33 122   & 133   & 156 \\
        2     & 66 112   & 135   & 155 \\
        3     & 77 150   & 139   & 158 \\
        4     & 55 145   & 135   & 159 \\
        5     & 44 150   & 130   & 200 \\
    \bottomrule
\end{tabular}%
\hspace{2.0ex}
\begin{tabular}{rrRR}
    \toprule
              & A     & B     & C \\
    \midrule
        1     & 33 122   & 133   & 156 \\
        2     & 66 112   & 135   & 155 \\
        3     & 77 150   & 139   & 158 \\
        4     & 55 145   & 135   & 159 \\
        5     & 44 150   & 130   & 200 \\
    \bottomrule
\end{tabular}%
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.