2

This question already has an answer here:

I have two questions related to the MWE shown:

  • How to append a percent sign to only cells of a column, or of a row by using siunitx package whether the tabular is defined by row or by columns. ? (I know I can put it only in the header but it's not the point).
  • How to add a vertical space, it doesn't work with the commented \vspace*{2cm}?

PS: I am not familiar with this package yet.

Here is a simplified MWE picked from here:

\documentclass[preview,border=5pt]{standalone}
\usepackage{booktabs}
\usepackage{siunitx}    
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\begin{document}    
\begin{table}
\centering
%defined by rows
\begin{tabular}{ l*{5}{S[input-symbols = {()},
                              table-space-text-post=\ ,
                              table-format=-1.2]}}
\toprule
\multicolumn{4}{c}{Panel A: $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low}  & \mc{Med}  & \mc{High} \\  \midrule
MV  & 1.64  &  1.14  &  1.58  \\
    & 1.17  &  0.97  &  0.87  \\
TA  & 1.90  &  1.03  &  0.88   \\
\bottomrule
\end{tabular}
%\vspace{2cm}

%defined by columns
\begin{tabular}{ c*{4}{S[input-symbols = {()},
                              table-space-text-post=\ ,
                              table-format=-1.2]}}
\toprule
\multicolumn{4}{c}{Panel A:  $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low}  & \mc{Med}  & \mc{High} \\  \midrule
MV  & 1.64  &  1.14  &  1.58  \\
    & 1.17  &  0.97  &  0.87  \\
TA  & 1.90  &  1.03  &  0.88   \\
\bottomrule
\end{tabular}
\end{table}        
\end{document}

marked as duplicate by ArTourter, Henri Menke, Stefan Pinnow, user36296, Claudio Fiandrino Jul 9 '16 at 13:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Usually units are better left mentioned in the stub (either vertically or horizontally). – daleif Jul 9 '16 at 12:13
1

(I will delete this soon)

The following code is supposed to append % to only the last 3 columns, but it does only append % to the two last columns in addition to an ugly space on the last column.

enter image description here

\documentclass[preview,border=5pt]{standalone}
\usepackage{booktabs}
\usepackage{siunitx}

\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\begin{document}

\begin{table}
\centering
%defined by columns
\begin{tabular}{ c c*{3}{S[input-symbols = {()},
                              table-space-text-post=\si{\,\%}\ ,
                              table-format=-1.2]<{\,\%}}}
\toprule
\multicolumn{4}{c}{Panel A:  $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low}  & \mc{Med}  & \mc{High} \\
\midrule
MV  & 1.64  &   1.14  &  1.58   \\
& 1.17  & 0.97 &  0.87  \\
TA   &  1.90      &  1.03     &  0.88   \\
\bottomrule
\end{tabular}
\end{table}

\end{document}
  • see edit of my answer. Discrepancy of positioning of % is know issues, however in my proposed solutions are not so extreme. You also still have one column more defined as are used in table. – Zarko Jul 9 '16 at 12:31
1

To add % to each cell in S column type is the same as at other column types:

 S[....]<{\%}

With siunitx to tables oriented option you can make fine tuning of apperance o %. Two examples are in MWE below:

\documentclass[preview,border=5pt]{standalone}
\usepackage{booktabs}
\usepackage{siunitx}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\begin{document}
\begin{table}
\centering
%defined by rows
\begin{tabular}{ c *{3}{S[input-symbols={()},
                          table-format=-1.2]<{\,\%}
               }}
\toprule
\multicolumn{4}{c}{Panel A: $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low}  & \mc{Med}  & \mc{High} \\  \midrule
MV  & 1.64  &  1.14  &  1.58  \\
    & 1.17  &  0.97  &  0.87  \\
TA  & 1.90  &  1.03  &  0.88   \\
\bottomrule
\end{tabular}
\vspace{0.5cm}

%defined by columns
\begin{tabular}{ c *{3}{S[input-symbols={()},
                          table-format=-1.2,
                          table-space-text-post=\,]<{\,\%}}
                }
\toprule
\multicolumn{4}{c}{Panel A:  $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low}  & \mc{Med}  & \mc{High} \\  \midrule
MV  & 1.64  &  1.14  &  1.58  \\
    & 1.17  &  0.97  &  0.87  \\
TA  & 1.90  &  1.03  &  0.88   \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

Edit: I n your MWE (which I didn't inspect enough carefully) you have defined one column more than are used in table. I correct this. Also I show that \vspace{0.5cm} works.

  • No i meant to add % to all cells of a single column or of a single line, sorry for the missunderstanding, for both scenarios does it count if the table if defined by it rows or columns. – SAM Jul 9 '16 at 12:10
  • @SAM, sorry, I don't understand your comment. For single column with % you need define column type for this column separately. – Zarko Jul 9 '16 at 12:14
  • yes c c*{3}{S[input-symbols = {()}, table-space-ext-post=\si{\,\%}\ ,table-format=-1.2]<{\,\%}}} doesnt work this way it supposed to append % to the last 3 columns but it does only for the last two ones – SAM Jul 9 '16 at 12:18
  • There are 4 columns not 3 look at the pic i don't understand, also \multicolumn{4}<<, MV & 1.64 & 1.14 & 1.58 there are four entries so 4 columns what i am missing ? – SAM Jul 9 '16 at 12:31
  • @SAM yes, altogether. In question you actually define 6 columns: one c and five S, in my first version of answer I reduce to 1 c +4 S and after than to 1 c + 3 S (what is correct. But seems if you add empty column (for example c type) with zero with, probably you will eliminate discrepancy of % position in lastS column. – Zarko Jul 9 '16 at 13:32

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