TransWikia.com

multi table cline disconnected

TeX - LaTeX Asked on November 28, 2020

usepackage{multirow}
usepackage{array}

makeatletter
newcommand{thickhline}{%
    noalign {ifnum 0=`}fi hrule height 1pt
    futurelet reserved@a @xhline
}
newcolumntype{"}{@{hskiptabcolsepvrule width 1pthskiptabcolsep}}
makeatother


begin{table}[h]
renewcommand{arraystretch}{1.5}
caption{Summary of statistical analysis results (*: $p$,textless,.05, **: $p$,textless,.01, ***: $p$,textless,.001).}
label{SecondEXPResultTable}
resizebox{1textwidth}{!}{%
begin{tabular}{l||ccl"l||ccl}
thickhline
textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test} &
  textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test}  thickhline
multirow{2}{*}{textbf{Distraction}} &
  multirow{2}{*}{$alpha$,=,.91} &
  multirow{2}{*}{$chi^2$,=,33.97, $p$,$<$,.001} &
  multirow{2}{*}{begin{tabular}[c]{@{}c@{}}DF $>$ TP*** DF $>$ STP***end{tabular}} &
  textbf{Spatial Presence} &
  $alpha$,=,.9 &
  $chi^2$,=,6.97, $p$,$<$,.05 &
  DF $>$ TP***  cline{5-8}
 &
   &
   &
   &
  textbf{AR Implausibility} &
  $alpha$,=,.67 &
  $chi^2$,=,8.75, $p$,$<$,.05 &
  DF $>$ TP**  hline
textbf{Visual Inconsistency} &
  $alpha$,=,.61 &
  $chi^2$,=,0.63, $p$,$>$,0.1 &
   &
  textbf{Animalism} &
  $alpha$,=,.87 &
  $chi^2$,=,9.28, $p$,$>$,.001 &
  begin{tabular}[c]{@{}c@{}}DF $<$ TP* DF $<$ STP*end{tabular}  
  thickhline
end{tabular}
vspace{-2em}
}
end{table}

enter image description here

Above figure is my problem.
Cline{5-8} command is not connected the borderline next to it.

I think, newcolumntype{"} make a problem. there is a hskip.

But I don’t know how to fix it. because I need this command for thick line.

I just want connect (cline) until next border line.

4 Answers

A small variation of Mico's answer with a littler more focus on the separation of the two halves of the table, aligned < and > in columns 4 and 8 and aligned = in columns 2 and 6, as well as slightly different column widths.

enter image description here

documentclass{article}
usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably

usepackage{makecell}

usepackage{tabularx,ragged2e,booktabs}
newcolumntype{Y}{>{RaggedRightarraybackslashhspace{0pt}}X}
renewcommandtabularxcolumn[1]{m{#1}}

begin{document}

begin{table}[h]
caption{caption text}
label{key}
begin{tabularx}{textwidth}{@{} Yccl Yccl @{}}
toprule
Measure & multicolumn{3}{c}{Tests} & Measure & multicolumn{3}{c@{}}{Tests} 
cmidrule(lr){2-4} cmidrule(l){6-8}
& Cronbach & Friedman & Post-hoc & & Cronbach & Friedman & Post-hoc 
cmidrule(r){1-4} cmidrule(l){5-8}

Distraction &
  $alpha=.91$ &
  makecell{$chi^2=33.97$, $p<.001$} &
  makecell[l]{DF$>$TP${}^{***}$ DF$>$STP${}^{***}$} &
Spatial presence &
  $alpha=.9$phantom{0} &
  makecell{$chi^2=6.97$, $p<.05$} &
  DF$>$TP${}^{***}$  
  addlinespace % cmidrule{5-8}
  & & & &
AR implausibility &
  $alpha=.67$ &
  makecell{$chi^2=8.75$, $p<.05$} &
  DF$>$TP${}^{**}$  
addlinespace % midrule
Visual inconsistency &
  $alpha=.61$ &
  makecell{$chi^2=0.63$, $p>0.1$} & &
Animalism &
  $alpha=.87$ &
  makecell{$chi^2=9.28$, $p>.001$} &
  makecell[l]{DF$<$TP${}^{*}$ DF$<$STP${}^{*}$}  
bottomrule
end{tabularx}

smallskip
Statistical significance levels: ${}^{*}$   $p<.05$; 
                                 ${}^{**}$  $p<.01$; 
                                 ${}^{***}$ $p<.001$
end{table}

end{document}

Here is another small variation:

enter image description here

documentclass{article}
usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably

usepackage{makecell}
usepackage{booktabs}

begin{document}

begin{table}[h]
caption{caption text}
label{key}
centering
begin{tabular}{lcccl}
toprule
Measure & multicolumn{4}{c}{Tests} 
cmidrule{2-5}
& Cronbach & multicolumn{2}{c}{Friedman} & makecell{Post-hoc} 
midrule 

Distraction &
  $alpha=.91$ &
  $chi^2=33.97$, & $p<.001$ &
  DF$>$TP${}^{***}$,  DF$>$STP${}^{***}$ 

Visual inconsistency &
  $alpha=.61$ &
  $chi^2=0.63$,phantom{0} & $p>0.1$phantom{0} & 
  
Spatial presence &
  $alpha=.9$phantom{0} &
  $chi^2=6.97$,phantom{0} &  $p<.05$phantom{0} &
  DF$>$TP${}^{***}$  
  
AR implausibility &
  $alpha=.67$ &
  $chi^2=8.75$,phantom{0} & $p<.05$phantom{0} &
  DF$>$TP${}^{**}$  

Animalism &
  $alpha=.87$ &
  $chi^2=9.28$,phantom{0} & $p>.001$ &
  DF$<$TP${}^{*}$,  DF$<$STP${}^{*}$  
bottomrule
multicolumn{5}{l}{Statistical significance levels: ${}^{*}$   $p<.05$;  ${}^{**}$  $p<.01$;  ${}^{***}$ $p<.001$}
end{tabular}

end{table}

end{document}

Correct answer by leandriis on November 28, 2020

Gap at cline is caused by column of " type, which you not consider in your cline settings. Instead of your lines definitions I rather use standard possibilities offered by array and makecell packages. Since you not provide any information about your document package layout, I use `standalone and focus only on table:

documentclass[margin=3mm]{standalone}
usepackage{array, makecell, multirow}

begin{document}
%begin{table}[h]
renewcommand{arraystretch}{1.5}
%caption{Summary of statistical analysis results (*: $p < .05$, **: $p < .01$, ***: $p < .001$).}

%label{SecondEXPResultTable}

begin{tabular}{l||ccl !{vrule width 1pt} l||ccl}
    Xhline{1pt} % defined in makecell
textbf{Measure} 
    &   textbf{Cronbach test} 
        &   textbf{Friedman test} 
            &   textbf{Post-hoc test} 
                &   textbf{Measure} 
                    &   textbf{Cronbach test} 
                        &   textbf{Friedman test} 
                            &   textbf{Post-hoc test}   
    Xhline{1pt}
multirow{2}{*}{textbf{Distraction}} 
    &   multirow{2}{*}{$alpha$,=,.91} 
        &   multirow{2}{*}{$chi^2$,=,33.97, $p$,$<$,.001} 
            &   $mathrm{DF} > mathrm{TP}$***
                &   textbf{Spatial Presence} 
                    &   $alpha$,=,.9 
                        &   $chi^2$,=,6.97, $p$,$<$,.05 
                            &   DF $>$ TP***  
    cline{5-8}
    &   &   &   $mathrm{DF} > mathrm{STP}$***
                &   textbf{AR Implausibility} 
                    &   $alpha$,=,.67 
                        &   $chi^2$,=,8.75, $p$,$<$,.05 
                            &   DF $>$ TP**  
    hline
textbf{Visual Inconsistency} 
    &   $alpha = .61$ 
        &   $chi^2 = 0.63, p >0.1$ 
            &   &   textbf{Animalism} 
                    &   $alpha = .87$ 
                        &   $chi^2 = 9.28, p > .001$ 
                            &   makecell{DF $<$ TP* DF $<$ STP*} 
    Xhline{1pt}
end{tabular}
%end{table}
end{document}

enter image description here

Addendum: Your table is very wide, so you may consider to write column headers in two lines and use smaller font size for table:

documentclass{article}
usepackage[showframe,  % in real document delete this option
            margin=20mm]{geometry}

usepackage{array, makecell, multirow}
renewcommandtheadfont{bfseriesfootnotesizelinespread{0.84}selectfont}

begin{document}
begin{table}[ht]
caption{Summary of statistical analysis results (*: $p < .05$, **: $p < .01$, ***: $p < .001$).}
label{SecondEXPResultTable}
    centering
    renewcommand{arraystretch}{1.5}
    setlengthtabcolsep{3pt}
    small
begin{tabular}{@{}l||lll !{vrule width 1pt} l||lll @{}}
    Xhline{1pt}
thead{Measure} 
    &   thead{Cronbach test} 
        &   thead{Friedman test} 
            &   thead{Post-hoc test} 
                &   thead{Measure} 
                    &   thead{Cronbach test} 
                        &   thead{Friedman test} 
                            &   thead{Post-hoc test}   
    Xhline{1pt}
multirow{2}{*}{textbf{Distraction}} 
    &   multirow{2}{*}{$alpha = .91$} 
        &   multirow{2}{*}{$chi^2 = 33.97$***}
            &   $mathrm{DF} > mathrm{TP}$***
                &   textbf{Spatial Presence} 
                    &   $alpha = .9$ 
                        &   $chi^2 = 6.97$*
                            &   $mathrm{DF} > mathrm{TP}$***  
    cline{5-8}
    &   &   &   $mathrm{DF} > mathrm{STP}$***
                &   textbf{AR Implausibility} 
                    &   $alpha = .67$ 
                        &   $chi^2 =8.75$*
                            &   $mathrm{DF} > mathrm{TP}$**  
    hline
thead{Visual Inconsistency} 
    &   $alpha = .61$ 
        &   $chi^2 = 0.63$**
            &   &   textbf{Animalism} 
                    &   $alpha = .87$ 
                        &   $chi^2 = 9.28$***
                            &   makecell[l]{$mathrm{DF} < mathrm{TP}$* 
                                             $mathrm{DF} < mathrm{STP}$*} 
    Xhline{1pt}
end{tabular}
end{table}
end{document}

enter image description here

(gray lines indicate text borders)

Answered by Zarko on November 28, 2020

I would spend most of my time on making the table more legible, say by not using resizebox, by allowing line breaks in cells, by not using textbf in the headers, and by providing more visual structure to the header material. Oh, I'd also use fewer horizontal lines -- and no vertical lines at all.

The following screenshot contrasts the table that's produced by the OP's code and that table that may be generated by implementing the preceding recommendations. I daresay that the second is more likely to entice your readers to actually study the table's contents.

enter image description here

documentclass{article}
usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably

usepackage{multirow,array,graphicx}
makeatletter
newcommand{thickhline}{%
    noalign {ifnum 0=`}fi hrule height 1pt
    futurelet reserved@a @xhline}
newcolumntype{"}{@{hskiptabcolsepvrule width 1pthskiptabcolsep}}
makeatother

%% new code, for second table
usepackage{tabularx,ragged2e,booktabs}
newcolumntype{L}[1]{>{RaggedRighthspace{0pt}hsize=#1hsize}X}
newcolumntype{C}[1]{>{Centeringhspace{0pt}hsize=#1hsize}X}
renewcommandtabularxcolumn[1]{m{#1}}

begin{document}


begin{table}[h]
renewcommand{arraystretch}{1.5}
caption{Summary of statistical analysis results (*: $p<.05$; **: $p<.01$; ${}^{***}$: $p<.001$).}
label{SecondEXPResultTable}

resizebox{1textwidth}{!}{%
begin{tabular}{l||ccl"l||ccl}
thickhline
textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test} &
  textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test}  thickhline
multirow{2}{*}{textbf{Distraction}} &
  multirow{2}{*}{$alpha=.91$} &
  multirow{2}{*}{$chi^2=33.97$, $p<.001$} &
  multirow{2}{*}{%
      begin{tabular}[c]{@{}c@{}}
        DF $>$ TP*** 
        DF $>$ STP***
      end{tabular}} &
  textbf{Spatial Presence} &
  $alpha=.9$ &
  $chi^2=6.97$, $p<.05$ &
  DF $>$ TP***  cline{5-8}
  & & & &
  textbf{AR Implausibility} &
  $alpha=.67$ &
  $chi^2=8.75$, $p$,$<$,.05 &
  DF $>$ TP**  hline
textbf{Visual Inconsistency} &
  $alpha=.61$ &
  $chi^2=0.63$, $p$,$>$,0.1 &
   &
  textbf{Animalism} &
  $alpha=.87$ &
  $chi^2=9.28$, $p$,$>$,.001 &
  begin{tabular}[c]{@{}c@{}}
     DF $<$ TP* 
     DF $<$ STP*
  end{tabular}  
  thickhline
end{tabular}
vspace{-2em}
}
end{table}



begin{table}[h]
setlengthtabcolsep{3pt} % default: 6pt
caption{Second try.strut}
label{Second}


begin{tabularx}{textwidth}{@{} 
     L{0.97}C{0.96}C{0.97}C{1.10} 
     L{0.99}C{0.99}C{0.99}C{1.03} @{}}
toprule
Measure & multicolumn{3}{c}{Tests} & Measure & multicolumn{3}{c@{}}{Tests} 
cmidrule(lr){2-4} cmidrule(l){6-8}
& Cronbach & Friedman & Post-hoc & & Cronbach & Friedman & Post-hoc 
midrule

Distraction &
  $alpha=.91$ &
  $chi^2=33.97$, $p<.001$ &
  mbox{DF$>$TP${}^{***}$} mbox{DF$>$STP${}^{***}$} &
Spatial presence &
  $alpha=.9$ &
  $chi^2=6.97$, $p<.05$ &
  DF$>$TP${}^{***}$  
  addlinespace % cmidrule{5-8}
  & & & &
AR implausibility &
  $alpha=.67$ &
  $chi^2=8.75$, $p<.05$ &
  DF$>$TP${}^{**}$  
addlinespace % midrule
Visual inconsistency &
  $alpha=.61$ &
  $chi^2=0.63$, $p>0.1$ & &
Animalism &
  $alpha=.87$ &
  $chi^2=9.28$, $p>.001$ &
  mbox{DF$<$TP${}^{*}$} mbox{DF$<$STP${}^{*}$}  
bottomrule
end{tabularx}

smallskip
Statistical significance levels: ${}^{*}$   $p<.05$; 
                                 ${}^{**}$  $p<.01$; 
                                 ${}^{***}$ $p<.001$
end{table}

end{document}

Answered by Mico on November 28, 2020

As said in other answers, the table of the OP is certainly too wide. However, I provide here a solution to draw the desired rule in the table as it is. I don't bother whether the table will fit in the size of the current text block.

With {NiceTabular} of nicematrix, you can always draw whatever rule you want in your tabular by using Tikz and the PGF/Tikz nodes created by nicematrix.

documentclass{article}

usepackage{geometry}
geometry{left=2.2cm,right=2.2cm,top=2cm,bottom=2cm,papersize={29.7cm,21cm}}

usepackage{nicematrix}
usepackage{tikz}

usepackage{multirow}
usepackage{array}

makeatletter
newcommand{thickhline}{%
    noalign {ifnum 0=`}fi hrule height 1pt
    futurelet reserved@a @xhline
}
newcolumntype{"}{@{hskiptabcolsepvrule width 1pthskiptabcolsep}}
makeatother

begin{document}

begin{table}[h]
renewcommand{arraystretch}{1.5}
caption{Summary of statistical analysis results (*: $p$,textless,.05, **: $p$,textless,.01, ***: $p$,textless,.001).}
label{SecondEXPResultTable}
begin{NiceTabular}{l||ccl"l||ccl}
thickhline
textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test} &
  textbf{Measure} &
  textbf{Cronbach test} &
  textbf{Friedman test} &
  textbf{Post-hoc test}  thickhline
multirow{2}{*}{textbf{Distraction}} &
  multirow{2}{*}{$alpha$,=,.91} &
  multirow{2}{*}{$chi^2$,=,33.97, $p$,$<$,.001} &
  multirow{2}{*}{begin{tabular}[c]{@{}c@{}}DF $>$ TP*** DF $>$ STP***end{tabular}} &
  textbf{Spatial Presence} &
  $alpha$,=,.9 &
  $chi^2$,=,6.97, $p$,$<$,.05 &
  DF $>$ TP***  
 &
   &
   &
   &
  textbf{AR Implausibility} &
  $alpha$,=,.67 &
  $chi^2$,=,8.75, $p$,$<$,.05 &
  DF $>$ TP**  hline
textbf{Visual Inconsistency} &
  $alpha$,=,.61 &
  $chi^2$,=,0.63, $p$,$>$,0.1 &
   &
  textbf{Animalism} &
  $alpha$,=,.87 &
  $chi^2$,=,9.28, $p$,$>$,.001 &
  begin{tabular}[c]{@{}c@{}}DF $<$ TP* DF $<$ STP*end{tabular}  
  thickhline
CodeAfter
tikz draw ([xshift=-tabcolsep]row-3-|col-5) -- (row-3-|col-9) ;
end{NiceTabular}
vspace{-2em}
end{table}

end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

Answered by F. Pantigny on November 28, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP