# "Dividers" with TikZ

I want to draw the structure of my thesis with TikZ. A rough sketch in Paint:

The nodes have been easy so far, but I could not find a good solution for the dividing lines with the label. For example, I managed to place a node called "Preliminaries" above the "Introduction" node and some arbitrary distance to the left using the let solution from this question, and thought of drawing a line using its northwest anchor. But I don't know how to make sure that the line is at least as wide as the picture (as determined by the width of the widest row of chapter nodes) or how to calculate an endpoint for the line such that it extends the same distance right and left from the first chapter node's center.

How do I get the horizontal dividers between my nodes, extending for the whole width of the graphic?

    \documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\begin{document}

\begin{figure}
\centering

\begin{tikzpicture}[
chapter/.style={
rectangle,
minimum width=8mm,
minimum height=3mm,
rounded corners=1mm,
align=center,
draw
},
font=\sffamily
]
\node [chapter](introduction){
\textbf{Introduction} \\
Motivation, goals and contribution
};
\node [chapter, below=4mm of introduction.south](background){
\textbf{Background} \\
Context and terms
};

% This tries to make Preliminaries'' a node, but maybe this is not the best approach anyway
%\draw ($(introduction.north west)+(-1,0.5)$) -- ($(introduction.north east)+(1,0.5)$);
%\path let \p1 = (introduction.north) in node (preliminaries) at (-5, \y1+10)  {
% Preliminaries
%};
\end{tikzpicture}

\caption{Structure of the thesis}
\label{fig:structure-of-the-thesis}
\end{figure}

\end{document}

• Some other possibilities would be to model the structure after a filesystem tree or this 'architecture model'. I think both would better represent the structure in a visual manner. (For instance, why are the appendices grouped in your diagram as part of the 'conclusion'?)
– jon
Feb 11 '17 at 22:08

Like this?

I in above image consider your (rather simple) image:

\documentclass{article}
\usepackage[showframe,% only for test page layout
margin=30mm]{geometry}
\usepackage{tikz}

\begin{document}
\begin{figure}%[ht]
\centering
\begin{tikzpicture}[
node distance = 7mm and 4mm,
every node/.style = {font=\bfseries\itshape},
chapter/.style = {rectangle, draw, semithick, rounded corners,
text width=44mm, minimum height=11mm, align=center,
ys/.style = {yshift=-7mm}
]
\draw[thick] (0,0)  coordinate (A1)
node[below right] {Preliminaries}
-- + (\textwidth,0)
coordinate (B1);
\node (ch1) [chapter, below=of $(A1)!0.5!(B1)$]         {Introduction};
\node (ch2) [chapter, below=of ch1]                     {Background};
\draw[thick] ([ys] A1 |- ch2.south)  coordinate (A2)
node[below right] {Problem states}
-- + (\textwidth,0)
coordinate (B2);
\node (ch3) [chapter, below  left=of $(A2)!0.5!(B2)$]   {State of the Art};
\node (ch4) [chapter, below right=of $(A2)!0.5!(B2)$]   {Building of Theory};
\draw[thick] ([ys] A1 |- ch3.south)  coordinate (A3)
node[below right] {Solution}
-- + (\textwidth,0)
coordinate (B3);
\node (ch5) [chapter, below=of $(A3)!0.5!(B3)$]         {My New Theory};
\node (ch6) [chapter, below=of ch5]                     {Validation of the Method};
\draw[thick] ([ys] A1 |- ch6.south)  coordinate (A4)
node[below right] {Conclusion}
-- + (\textwidth,0)
coordinate (B4);
\node (ch7) [chapter, below=of $(A4)!0.5!(B4)$]         {Discussion and conclusions};
\node (ap1) [chapter, below  left=of ch7]               {Appendix A};
\node (ap2) [chapter, below =of ch7]                    {Appendix B};
\node (ap3) [chapter, below right=of ch7]               {Appendix C};
\end{tikzpicture}
\caption{Structure of the thesis}
\label{fig:structure-of-the-thesis}
\end{figure}
\end{document}


If you draw all the boxes first you can use current bounding box to get the left and right borders of the graphics.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
TestBox/.style={draw,minimum width=3cm,minimum height=3em,rounded corners=2mm}]
\node[TestBox] (A) {A};
\node[TestBox,below left= of A](B){B};
\node[TestBox,below right= of A](C){C is a bit longer than the other boxes};
\node[TestBox,below=of $(B.south east)!0.5!(C.south west)$](D) {D};
\node[TestBox,below=of D](E) {E};
%%
\coordinate(BBw) at ($(current bounding box.west)+(-5mm,0)$);
\coordinate(BBe) at ($(current bounding box.east)+(5mm,0)$);
\coordinate(Level1) at ($(C.south)!0.5!(D.north)$);
\draw (Level1 -| BBw) -- (Level1-|BBe) node[pos=0,anchor=north west]{Label of line};
\end{tikzpicture}
\end{document}