[Tex/LaTex] How to display contents of a tree grid in a latex table

tablestrees

I am working on displaying a nested bill of material in tree grid in a latex document.

Is there a package available that can help with this?

Tree Grid

A short example of my current table

\begin{table}[h]
\centering
\begin{tabular}{| l | l | c | c | r | r | }
\hline
Item & Description & Quantity & Units & Cost & Extended \\ 
\hline
\rowcolor{lightgray} Pulley &  Pulley & 1.0 &  Each &  15136.8 &  15136.8 \\ 
\rowcolor{lightgray} Shell &  996.5 ID x 1856 Plate 4140 32mm & 1.0 &  Each &  3516.04 &      3516.04 \\ 
\hspace{0.3cm}  PM00000019 &  Weld MIG & 25.6763 &  Kg &  1.2 &  30.81 \\ 
\hspace{0.3cm}  PM00000012 &  Weld MIG & 1.0135 &  Hr &  90.0 &  91.22 \\ 
\hspace{0.3cm}  PM00000013 &  Weld Prep & 1.7373 &  Hr &  90.0 &  156.36 \\ 
\hspace{0.3cm}  PM00000108 &  Plate 4140 32mm & 1483.0046 &  Kg &  2.15 &  3188.46 \\ 
\hspace{0.3cm}  PM00000010 &  Plate Roll & 0.5465 &  Hr &  90.0 &  49.19 \\ 
\rowcolor{lightgray} EnddiskA &  996.5 x 355 x 70 Plate 1045 & 1.0 &  Each &  1445.32 &  1445.32 \\ 
\hspace{0.3cm}  PM00001024 &  Ring Backing 270 x 390 x 16 & 1.0 &  Each &  39.73 &  39.73 \\ 
\hspace{0.3cm}  PM00000115 &  Plate 4140 70mm & 578.2036 &  Kg &  2.43 &  1405.03 \\ 
\hspace{0.3cm}  PM00000020 &  Plasma Cutter & 0.2141 &  Hr &  1.0 &  0.21 \\ 
\hspace{0.3cm}  PM00000021 &  Oxy Cutter & 0.5586 &  Hr &  1.0 &  0.56 \\ 
\hspace{0.3cm}  PM00000133 &  Plate 1045 16mm & 17.2547 &  Kg &  2.29 &  39.51  \\
\hline
\end{tabular}
\caption{Bill of Material}
\label{tab:my_label}
\end{table}

Best Answer

You can try with tikzmark library:

\documentclass{article}
\usepackage{colortbl}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{| l | l | c | c | r | r | }
\hline
Item & Description & Quantity & Units & Cost & Extended \\ 
\hline
\rowcolor{lightgray} Pulley &  Pulley & 1.0 &  Each &  15136.8 &  15136.8 \\ 
\rowcolor{lightgray} \tikzmark{Sh}Shell &  996.5 ID x 1856 Plate 4140 32mm & 1.0 &  Each &  3516.04 &      3516.04 \\ 
\hspace{0.3cm}  \tikzmark{PM19}PM00000019 &  Weld MIG & 25.6763 &  Kg &  1.2 &  30.81 \\ 
\hspace{0.3cm}  \tikzmark{PM12}PM00000012 &  Weld MIG & 1.0135 &  Hr &  90.0 &  91.22 \\ 
\hspace{0.3cm}  PM00000013 &  Weld Prep & 1.7373 &  Hr &  90.0 &  156.36 \\ 
\hspace{0.3cm}  PM00000108 &  Plate 4140 32mm & 1483.0046 &  Kg &  2.15 &  3188.46 \\ 
\hspace{0.3cm}  PM00000010 &  Plate Roll & 0.5465 &  Hr &  90.0 &  49.19 \\ 
\rowcolor{lightgray} EnddiskA &  996.5 x 355 x 70 Plate 1045 & 1.0 &  Each &  1445.32 &  1445.32 \\ 
\hspace{0.3cm}  PM00001024 &  Ring Backing 270 x 390 x 16 & 1.0 &  Each &  39.73 &  39.73 \\ 
\hspace{0.3cm}  PM00000115 &  Plate 4140 70mm & 578.2036 &  Kg &  2.43 &  1405.03 \\ 
\hspace{0.3cm}  PM00000020 &  Plasma Cutter & 0.2141 &  Hr &  1.0 &  0.21 \\ 
\hspace{0.3cm}  PM00000021 &  Oxy Cutter & 0.5586 &  Hr &  1.0 &  0.56 \\ 
\hspace{0.3cm}  PM00000133 &  Plate 1045 16mm & 17.2547 &  Kg &  2.29 &  39.51  \\
\hline
\tikz[remember picture] \foreach \i in {PM19,PM12} \draw[overlay] (pic cs:Sh) |- ([yshift=1.5mm]pic cs:\i);
\end{tabular}
\caption{Bill of Material}
\label{tab:my_label}
\end{table}
\end{document}

enter image description here