我有一段乳胶代码:
\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}
如何避免在第 2 列和第 3 列的底部以及第 1 列的顶部出现双线?
我只需要每个单元格单线边框。
答案1
尝试:
\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}
如果第一列中的所有单元格都具有相同的颜色背景,那么您可以按如下方式编写矩阵:
\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}