TransWikia.com

Tikz matrix node unwanted vskip in first column

TeX - LaTeX Asked on May 15, 2021

I have a strange vertical skip in a tikz matrix node within the first column I can not figure out how to eliminate:

MWE

documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix}
begin{document}

begin{tikzpicture}[xshift=1.75cm,yshift=3pt,
table/.style={
    matrix of nodes, row sep=-pgflinewidth, column sep=-pgflinewidth,
    nodes={rectangle,align=left,draw=black,font=scriptsize, 
        minimum height=1.5em,
        text depth=0.5ex,
        text height=2ex},
    nodes in empty cells,
    column 1/.style={text width=0.46textwidth},
    column 2/.style={text width=0.05textwidth},
    column 3/.style={text width=0.05textwidth},
    column 4/.style={text width=0.30textwidth},
    column 5/.style={text width=0.05textwidth},
    column 6/.style={text width=0.05textwidth}
    }]
node[matrix,table,anchor=north west] (first) at (0.5,4)
{
    Endogenes Konstrukt & $ R^2 $ & $ Q^2 $ & Exogene(s) Konstrukt(e) & $f^2$ & $VIF$  
    
    (KB) & 0,34 &  0,30 & (GA) & 0,53  & -  
};
end{tikzpicture}
end{document}

Any help is highly appreciated!

2 Answers

Just avoid CR between lines in your matrix. Or at least, use % for it not to be taken care.

documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix}
begin{document}

begin{tikzpicture}[xshift=1.75cm,yshift=3pt,
table/.style={
    matrix of nodes, row sep=-pgflinewidth, column sep=-pgflinewidth,
    nodes={rectangle,align=left,draw=black,font=scriptsize, 
        minimum height=1.5em,
        text depth=0.5ex,
        text height=2ex},
    nodes in empty cells,
    column 1/.style={text width=0.46textwidth},
    column 2/.style={text width=0.05textwidth},
    column 3/.style={text width=0.05textwidth},
    column 4/.style={text width=0.30textwidth},
    column 5/.style={text width=0.05textwidth},
    column 6/.style={text width=0.05textwidth}
    }]
node[matrix,table,anchor=north west] (first) at (0.5,4)
{
    Endogenes Konstrukt & $ R^2 $ & $ Q^2 $ & Exogene(s) Konstrukt(e) & $f^2$ & $VIF$  
   (KB) & 0,34 &  0,30 & (GA) & 0,53  & -  
};
end{tikzpicture}
end{document}

vertical skip

Correct answer by SebGlav on May 15, 2021

I would modified your MWE as follows:

documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix}

%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

begin{document}

noindentbegin{tikzpicture}[
table/.style={
    matrix of nodes, 
    nodes={minimum height=1.5em, text depth=0.5ex, text width=0.05textwidth,
           inner xsep=0.005textwidth, outer sep=0pt, anchor=center,
           draw, font=scriptsize, align=left},
    nodes in empty cells,
    inner sep=0pt, outer sep=0pt,
    column sep=-pgflinewidth,
    row sep=-pgflinewidth, 
    column 1/.style={nodes={text width=0.44textwidth}},
    column 4/.style={nodes={text width=0.30textwidth}},
    }]
matrix[table] (first)
{
Endogenes Konstrukt & $R^2$ & $Q^2$ & Exogene(s) Konstrukt(e)   & $f^2$ & $VIF$ 
(KB)                & 0,34  &  0,30 & (GA)                      & 0,53  & --    
};
end{tikzpicture}
end{document}

Observe differences in:

  • nodes style, which contain also width of narrower columns
  • defined matrix inner and outer separation (set to zero)
  • column styles (defined are only two)
  • removed are all shifts and nodes positions settings (which haven't any influence on matrix position)

enter image description here

Red lines in above image are added that matrix position in page is simpler to see.

Answered by Zarko on May 15, 2021

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