5

I have a piece of latex code:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}

\definecolor{arbitrary}{rgb}{0.9,1,1}

\begin{document}

    \pgfdeclarelayer{background}
    \pgfsetlayers{background,main}

    \begin{tikzpicture}
    \matrix (magic) [matrix of nodes,nodes={minimum width=3cm,minimum height=1cm,draw,very thin},draw,inner sep=0]
    {   |[fill=arbitrary]|\quad & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
         |[fill=arbitrary]|\quad & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
    };
%   \draw[thick,violet] (magic-2-1.east) to[out=180,in=270,looseness=0.5] (magic-2-1.north) to[out=270,in=0,looseness=0.5] (magic-2-1.west) to[out=0,in=90,looseness=0.5] (magic-2-1.south) to[out=90,in=180,looseness=0.5] (magic-2-1.east);
%   \draw[rounded corners=2pt,densely dashed,green!50!gray] ($(magic-1-2.center)+(-0.15,-0.25)$) rectangle ($(magic-1-3.center)+(0.15,0.25)$);

    \end{tikzpicture}

\end{document}

How can I avoid the double lines appearing in the bottom of columns 2 and 3, and top of 1st column?

Here is the sample image: enter image description here

I need only single line border for each cell.

7

Try:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix}

\definecolor{arbitrary}{rgb}{0.9,1,1}

\begin{document}
    \begin{tikzpicture}
\matrix (magic) [matrix of nodes,
                 nodes={draw, very thin,
                        minimum width=3cm, minimum height=1cm, 
                        inner sep=2mm, anchor=center}, % <--- added
                 inner sep=0pt, draw
                 ]
{   
|[fill=arbitrary]|
    & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
|[fill=arbitrary]|
    & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
};
    \end{tikzpicture}
\end{document}

enter image description here

In the case, that all cells in the first column have the same color background, than you can write your matrix as follows:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,
                matrix}

\definecolor{arbitrary}{rgb}{0.9,1,1}

\begin{document}
    \begin{tikzpicture}
\matrix (magic) [matrix of nodes,
                 nodes in empty cells,   
                 nodes={draw, very thin,
                        minimum width=3cm, minimum height=1cm, 
                        inner sep=2mm, anchor=center},
                 column 1/.style = {nodes={fill=arbitrary}},
                 inner sep=0pt, draw
                 ]
{   
    & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
    & \verb|\definecolor{arbitrary}{rgb}{0.9,1,1}| & \#ABCDEF \\
};
\draw[rounded corners=2pt,densely dashed,green!50!gray]
    ($(magic-1-2.center)+(-0.15,-0.25)$) rectangle ($(magic-1-3.center)+(0.15,0.25)$);
\draw[thick,violet]     (magic-2-1.east) 
            to[out=180,in=270,looseness=0.5] (magic-2-1.north)
            to[out=270,in=0,  looseness=0.5] (magic-2-1.west)
            to[out=0, in=90,  looseness=0.5] (magic-2-1.south)
            to[out=90,in=180, looseness=0.5] (magic-2-1.east);
    \end{tikzpicture}
\end{document}

enter image description here

  • Thanks! I have learnt that a table with different column width can be drawn with matrix of TikZ – Black Mild Sep 15 at 7:39

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.