1

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}
  • Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – cfr Feb 23 '15 at 0:38
  • What is the problem, exactly? I mean, 'yes, there is a package' but it is hard to know where the gaps in your knowledge are without seeing what you've got so far. So it is well nigh impossible to say anything useful. (Without just drawing the whole thing for you, of course.) – cfr Feb 23 '15 at 0:40
  • Hi. Clearly it's not difficult to display a table with latex. The question really is there an easy way to display a tree structure as shown in the Component ID column. – Andrew Feb 23 '15 at 0:42
  • Then why don't you post some code for the easy bit so people who are interested can help you with the hard bit? – cfr Feb 23 '15 at 0:44
  • Please post complete code i.e. a compilable document. This is much more useful than a mere fragment. – cfr Feb 23 '15 at 17:17
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.