Can you help me with creating this type of table in Latex ?
Thank you
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityJust for fun in my free time. I hope OP would provide a MME in the next question (if any) ^^
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=.75,font=\sffamily]
\begin{scope}[shift={(-.5,.5)}]
\clip[draw,rounded corners] (-4,-3) rectangle (5,2);
\fill[cyan] (-4,-1) rectangle +(1,1);
\fill[magenta] (3,0) rectangle +(1,1);
\draw (-4,-3) grid (5,2);
\draw[fill=white] (-2,-2) rectangle (3,1);
\end{scope}
\fill (-4,0) circle(.1) (4,-1) circle(.1);
\path node{XXX}
(-2,2) node{A}
++(0:1) node{B}
++(0:1) node{C}
++(0:1) node{D}
++(0:1) node{E}
(-2,-2) node{1}
++(0:1) node{2}
++(0:1) node{3}
++(0:1) node{4}
++(0:1) node{5};
\end{tikzpicture}
\end{document}
I would just use a matrix. As long as you do not draw the nodes at the corners, you will respect the rounded corners of the matrix node. For your convenience I added a shortcut n
which suppresses the draw.
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[n/.style={draw=none},font=\sffamily]
\path node[matrix of nodes,draw,rounded corners,inner sep=-\pgflinewidth/2,nodes in empty
cells,column sep=-\pgflinewidth,row sep=-\pgflinewidth,
cells={nodes={draw,sharp corners,minimum size=2em,anchor=center}}]
{ |[n]| & & A & B & C & D & E & & |[n]|\\
& & |[n]| & |[n]| & |[n]| & |[n]| & |[n]| & |[fill=red]| & \\
|[fill=blue!40]| \textbullet & & |[n]| & |[n]| & |[n]| & |[n]| & |[n]| & & \\
& & |[n]| & |[n]| & |[n]| & |[n]| & |[n]| & & \textbullet \\
|[n]| & & 1 & 2 & 3 & 4 & 5 & & |[n]|\\
} node{XXX};
\end{tikzpicture}
\end{document}
Or
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[n/.style={draw=none},font=\sffamily]
\path node[matrix of nodes,draw,rounded corners=2ex,inner sep=-\pgflinewidth/2,nodes in empty
cells,column sep=-\pgflinewidth,row sep=-\pgflinewidth,
cells={nodes={draw,sharp corners,minimum size=2em,anchor=center}}]
{ |[n]| & & A & B & C & D & E & & |[n]|\\
& & |[n]| & |[n]| & |[n]| & |[n]| & |[n]| & |[fill=red]| & \\
|[fill=blue!40]| \textbullet & & |[n]| & |[n]| & |[n]| \makebox[0pt][c]{XXX} & |[n]| & |[n]| & & \\
& & |[n]| & |[n]| & |[n]| & |[n]| & |[n]| & & \textbullet \\
|[n]| & & 1 & 2 & 3 & 4 & 5 & & |[n]|\\
};
\end{tikzpicture}
\end{document}
With {NiceTabular}
of nicematrix
(≥ 6.18). You need several compilations because nicematrix
uses PGF/Tikz nodes under the hood.
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\renewcommand{\arraystretch}{1.8}
\begin{NiceTabular}
[hvlines,rounded-corners,colortbl-like,columns-width=4mm]
{ccccccccc}
& & A & B & C & D & E \\
& & \Block{3-5}{xxx} & & & & & \cellcolor{red} \\
\Block[v-center,fill=blue!50]{}{\textbullet} \\
& & & & & & & & \Block[v-center]{}{\textbullet} \\
& & 1 & 2 & 3 & 4 & 5 \\
\end{NiceTabular}
\end{document}