I'm trying to create a table in LaTeX which contains a multirow as height as the rest of the table. This table appears lots of times in my document. The problem is that the second row can contain different numbers of linebreaks. But the multirow package takes in advance the number of rows instead of the total number of lines. Normally each time I use this table I have to count the real number of lines and edit the number into the multirow options.
Now I'm looking for a way to count the lines and adjust the multirow automatically. Maybe a counter could be helpful? I've tried that possibility with the tabline counter and this works quite well (after compiling the second time). A similar option taking in advance all lines inside the table would be great. On Google I've found the lineno package with the option edtable. This could probably help but I don't know how to use it for my problem. Does anyone have an idea to solve this?
\documentclass[a4paper,pagesize]{scrartcl}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{hhline}
\usepackage{array}
\usepackage[edtable]{lineno} %% Could be helpful?
\newcounter{tabline}
\newcolumntype{n}{>{\refstepcounter{tabline}\thetabline\enspace}l}
\begin{document}
\begin{table}[ht] \centering
\begin{tabular}{| n | >{\centering\arraybackslash}p{.4\textwidth} | > {\centering\arraybackslash}p{.4\textwidth} |}
\hline
TEST & TEST & \multirow{\ref{FOO}}{*} {\includegraphics[width=.4\textwidth]{example-image-golden}} \\ \hhline{--~|}
TEST & TEST & \\ \hhline{--~|}
TEST & TEST \linebreak HERE IS A LINEBREAK & \\ \hhline{--~|}
TEST & TEST & \\ \hhline{--~|}
TEST & TEST & \\ \hhline{--~|}
TEST & TEST \linebreak HERE IS ONE TOO & \\ \hhline{--~|}
TEST & TEST \linebreak AND ANOTHER ONE & \\ \hhline{--~|}
TEST & TEST & \\ \hhline{--~|}
TEST\label{FOO} & TEST & \\ \hline
\end{tabular}
\end{table}
The table contains~\ref{FOO} rows. \\
\end{document}