I want to draw multiple lines caption that is connected to a line. I observe that line may overwrite to second line.
Base figure example would be right hand side of the following figure (taken from https://en.wikipedia.org/wiki/Introduction_to_Algorithms second edition, page 223):
my code: (it generates an error but able to compile)
\documentclass[tikz, margin=3.14mm]{standalone}
\usepackage{siunitx}
\usepackage{tikzpeople}
\usetikzlibrary{positioning,calc,arrows.meta,arrows,matrix}
\usetikzlibrary{decorations.pathreplacing}
\tikzset{
mymat/.style={
matrix of math nodes,
minimum width=1cm,
minimum height=0.5cm,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
row sep=-\pgflinewidth,
outer sep=0pt,
inner sep=0pt
},
mymat3/.style={
matrix of math nodes,
minimum width=0.5cm,
minimum height=0.5cm,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
row sep=-\pgflinewidth,
outer sep=0pt,
inner sep=0pt
}
}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix[mymat,anchor=south west,style={nodes=draw}]
at (5*\x+0.3,-3.6)
(mat1)
{
400\\
100\\
};
\draw (mat1-1-1.north west) --++ (0,0.8);
\draw (mat1-1-1.north east) --++ (0,0.8);
\matrix[mymat3,right=25mm of mat1-1-1.east,anchor=east,style={nodes={draw,fill=gray!30}}]
(mat2)
{
1 & 2 & \dots\\
};
\matrix[mymat3,below=0.5 mm of mat2,style={nodes={draw,fill=gray!30}}]
(mat5)
{
1 & 2 & \dots\\
};
\path[->, -Latex]
(mat1-2-1.east) edge[] node [left] {} (mat5-1-1.west);
\path[->, -Latex]
(mat1-1-1.east) edge[] node [left] {} (mat2-1-1.west);
\foreach \i [count=\l from 0] in {2,...,1} \node[left= 0.1mm of mat1-\i-1] {\l};
\draw (mat2-1-1.north) --++ (0,0.5) node[align=center] {\tiny available\\\tiny life};
\draw (mat2-1-2.north) --++ (0,0.5) node[align=center] {\tiny core\\\tiny number};
\end{tikzpicture}
\caption{M1}\label{fig:M1}
\end{figure}
\end{document}
Output:
Here, I have done draw (mat2-1-1.north) --++ (0,0.5) node[align=center] {\tiny available\\\tiny life}; to link caption along with a line but the line is linked to the first sentences where it overwrites to text after the new line (life and number strings in the example). And also there is a gap in between the lines that I couldn't remove.
Desired picuture could be, or any variaty that captions won't collide :
Related answers:







minimum heightbut it didn't have any affect – alper Apr 10 '21 at 22:22column sep=-\pgflinewidth,to your matrix declaration, like you did for the rows, and changerow septo something positive. I'll edit my post to let you choose. – SebGlav Apr 11 '21 at 09:32mat3:minimum height=0.3cm,andtext height=2.1ex,but not sure would it be a proper solution – alper Apr 11 '21 at 15:07row sep=-\pgflinewidth, column sep=-\pgflinewidth,at which line in your original answer code? that would be helpful – alper Apr 11 '21 at 15:09mymat3/.style. Here, you only haverow sep=-\pgflinewidth. Play here with those settings. – SebGlav Apr 11 '21 at 15:27