# Drawing multiple lines and/or dashed lines under words

I'm trying to define tables for logical design in database course and I only need to write headers of columns, but the problem is that depending on whether one or multiple columns are primary keys or foreign keys, there must be one or multiple regular or dashed lines under headers.

It should be something like these:

(It doesn't matter if the table is defined with a 1xN table (like the first picture) or in one regular line (like the second picture). Only the underline(s) is important.

I'm familiar with the \underline command and basic tables in Tex, but I don't know how multiple lines can be drawn under multiple words. For example, if we have three headers a, b and c, and there is a line under a, b and another under b, c, I can's see how \underline can be used.

Any help would be appreciated.

Welcome! Generally the enthusiasm to help those who just upload some pictures and do not show what they have tried, and where they are stuck, is not too pronounced. It is possible to do all this, of course, here is a possible start. Most likely there are much more elegant solutions, though.

\documentclass{article}
\usepackage{tikz}
\newcommand\tikznode[2]{\tikz[remember picture]{\node(#1)[inner sep=0pt]{#2};}}
\begin{document}

\textsf{\textbf{OFFERING} (\tikznode{S}{S}TI\tikznode{D1}{D},
\tikznode{C}{C}OI\tikznode{D2}{D}, \tikznode{P}{P}ROFI\tikznode{D3}{D}),\dots) }

\begin{tikzpicture}[overlay,remember picture,blue]
\draw[-,densely dashed,thick,transform canvas={yshift=-2pt}] (S.south west) -- (D1.south east);
\draw[-,densely dashed,thick,transform canvas={yshift=-2pt}] (C.south west) -- (D2.south east);
\draw[-,densely dashed,thick,transform canvas={yshift=-2pt}] (P.south west) -- (D3.south east);
\draw[-,densely dashed,thick,transform canvas={yshift=-4pt}] (S.south west) -- (D2.south east);
\draw[-,thick,transform canvas={yshift=-6pt}] (S.south west) -- (D3.south east);
\end{tikzpicture}

\end{document}


And yes, I am aware that using TiKz for this is overkill, and that one can invent very sophisticated macros for all this. But I thought I could make a start in answering this (in principle interesting) question.

• Thanks a lot. I'm sorry, I added my main problem now, and I wasn't familiar with TiKz or similar packages so I had only tried \underline. – Karegar Dec 10 '17 at 6:33