1

I have the following table:

\begin{table}[h]
\caption{\label{tab:}Model 1 - Model output}
\centering
\begin{tabular}{l|c|c|c|c|c|c|c}
    \hline
    & coefficient & Std. Error & t-value & p-value & 2,5\% & 97,5\% & R-sqr\\
    \cline{1-7}
    \rowcolor{gray!6}  (Intercept) & -0.094 & 0.002 & -59.912 & 0 & -0.097 & -0.091 & \multirow{3}{*}{0.192}\\
    \cline{1-7}
    cost & 0.017 & 0.001 & 19.805 & 0 & 0.015 & 0.018 & \\
    \cline{1-7}
    \rowcolor{gray!6}  lead\_cost & -0.010 & 0.001 & -13.762 & 0 & -0.012 & -0.009 & \\
    \hline
\end{tabular}  \end{table}

And I want all \clines to behave in the same way, precisely as the first and the third \cline. Why is my second \cline not behaving like the first and the third? Precisely, why is my second \cline not as thin as the first or the third and rather looks exactly like a \hline? I red other posts related to this without getting the proposed solutions.

Fabio
  • 11
  • Welcome to TeX.SE. – Mico Aug 19 '19 at 11:01
  • (1) pelses make this into a full minimal example, that makes it easier for others to test your code. (2) To me it seems the lines are the same size, but row color covers most of the cline above it, and the about you see depends on the zoom level in the PDF viewer. – daleif Aug 19 '19 at 11:13
  • 1
    Possible duplicate: https://tex.stackexchange.com/a/39766/3929 – daleif Aug 19 '19 at 11:17
  • @daleif I agree and I tried to add the table so that you could see it immediately (if that is what you mean with "full minimal example"), but I am new to this forum and I didn't manage to include it, sorry :/ – Fabio Aug 19 '19 at 12:01
  • 1
    @Fabio it is not, look at Micos ecample below, it has everything you need to compile that example, document class, and minimal preamble. In your case one needs to know which packages provide \rowcolor (I even got it wrong when I tested the code) – daleif Aug 19 '19 at 12:04
  • @daleif full minimal example then means the full code from first to last line is that what it means? – Fabio Aug 19 '19 at 12:05
  • 1
    @Fabio something like that, but not the minimal, it should be such that the example gives the user what they need to replicate (or what ever) the problam at hand, not more. – daleif Aug 19 '19 at 12:19
  • 1
    We have seen several times where users forget to specify the document class, and it turns out that the problem goes away if you used article. Then we have just wasted time helping the user because of information that should have been added in the first place. This is why you'll see the comment about full MWE on such a high number of questions on the site. – daleif Aug 19 '19 at 12:21
  • @daleif I see. I will make sure to not do this again in the future, thanks for the remark! – Fabio Aug 19 '19 at 12:25
  • 1
    @Fabio I'd like to see the system automatically give users with a low score a link to a description on how to post a good question. Most never give this a thought and sometimes feel personally attached when we ask for a full minimal example. – daleif Aug 19 '19 at 12:32

1 Answers1

2

In my opinion, it's not a good idea to place the value of the goodness-of-fit statistic in one of the regressor rows; better to place it on a line by itself.

I also don't think that the striping of alternate rows does much for legibility; I'd therefore get rid of the striping. To really improve legibility, I would (a) align the numbers in the data columns on their respective decimal markers and (b) omit all vertical rules and use fewer, but well-spaced, horizontal rules.

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{booktabs,siunitx}
\newcolumntype{T}[1]{S[table-format=#1]}
\begin{document}

\begin{table}[h]
\caption{\label{tab:}Model 1 - Model output}
\centering
\begin{tabular}{@{} l T{-1.3} T{1.3} T{-2.3} c T{-1.3} T{-1.3} @{}}
    \toprule
    & {Coeff.} & {Std.\ Err.} & {$t$-value} & {$p$-value} & {2,5\%} & {97,5\%} \\
    \midrule
    (Intercept) & -0.094 & 0.002 & -59.912 & 0 & -0.097 & -0.091 \\    
    cost        &  0.017 & 0.001 &  19.805 & 0 &  0.015 &  0.018 \\    
    lead\_cost  & -0.010 & 0.001 & -13.762 & 0 & -0.012 & -0.009 \\
    \addlinespace
    R\textsuperscript{2} & 0.192\\ 
    \bottomrule
\end{tabular}  
\end{table}
\end{document} 
Mico
  • 506,678
  • I agree with your arguments about legibility. But nevertheless, if I really wanted to keep it my way, how would you solve the issue with \cline? – Fabio Aug 19 '19 at 12:02
  • I actually really like your table and I will use your style. Could you just tell me in a few words what your code after \begin{tabular} does? I am talking about {@{} l T{-1.3} T{1.3} T{-2.3} c T{-1.3} T{-1.3} @{}} – Fabio Aug 19 '19 at 12:46
  • @Fabio - In the preamble, you'll find the instruction \newcolumntype{T}[1]{S[table-format=#1]}. Basically, then, T{-1.3} is shorthand for S[table-format=-1.3]. The S column type, which is defined in the siunitx package, allows aligning numbers on their respective decimal markers. -1.3 means: "set aside space for a - (minus) symbol and 1 digit to the left of the decimal marker, and set aside 3 digits to the right of the decimal marker". The @{} particles serve to suppress whitespace padding to the left of the first column and to the right of the final column. – Mico Aug 19 '19 at 13:29
  • 1
    thanks to your replies I red now a lot about how proper tables are supposed to look like and what rules to follow. I had no idea and now I have so good looking tables I feel like a boss. also thank you for explaining me the {@{} l T{-1.3} T{1.3} T{-2.3} c T{-1.3} T{-1.3} @{}} I tried to decrypte it myself and it was so frustrating. you made my day, thank you so much <3 (you can "close" this thread now or I don't know how this works, but this is more than fine for me now). I will definitely come back here and try to be more precise and engaged in other topics etc. – Fabio Aug 19 '19 at 14:28
  • @Fabio -You're most welcome! If you believe that my answer fully addresses and solves the typesetting issue(s) you were looking to solve, feel free to "accept" it, by clicking on the checkmark symbol located at the upper-left of the answer. ;-) – Mico Aug 19 '19 at 14:59