I'm working on adapting the code from How to Optimize a TikZ Animation of Quicksort? to use TikZ with layers.
I want to add a layer that draws a rectangle with a very thick line. Additionally, I would like to include a line between the 7th and 8th elements, exactly in the middle of the vector.
Furthermore, the labels should be positioned between the colored cells. More details are provided in the code.
Desired output
This is the output I would like to achieve: 
Code
\documentclass[tikz, border=.2cm]{standalone} \usetikzlibrary{chains} % slide 11/52 \newcommand*\tikzqsset{\pgfqkeys{/tikz/qs}} \tikzqsset{ % default cell style vector/.style = {draw, shape=rectangle, minimum size = +0.7cm, outer sep = +0pt}, label/.style = {node distance = 0pt,font = \ttfamily\scriptsize}, % /tikz/label exists already % cells styles undiscovered/.style = {fill = white}, left/.style = {fill = red!30}, between/.style = {fill = yellow!30}, right/.style = {fill = blue!30}, % parsing style parse/.style args={#1#2}{qs/sc-#1/.try, node contents={#2}}, % defining styles sc-l/.style={in front of path, qs/undiscovered}, sc-L/.style={in front of path, qs/left}, sc-b/.style={in front of path, qs/between}, sc-r/.style={in front of path, qs/undiscovered}, sc-R/.style={in front of path, qs/right}, } \NewDocumentCommand{\DividiEtImpera}{ m }{ \tikz\path[node distance=+0pt, start chain=going right] { foreach[count=\i] \v in {#1}{ node[on chain, qs/vector, qs/parse/.expand once=\v] } } []; \tikz\draw[very thick] (chain-1.north west) rectangle (chain-16.south east); } \begin{document} \DividiEtImpera{l0, L1, L2, L3, L4, l5, b6, b7, b8, b9, b10, r11, r12, R13, R14, R15} % maxL label below and between 1 and 4 % maxRR label below and between 6 and 7 % maxLL label below and between 8 and 10 % maxR label below and between 13 and 15 \end{document} 

parse/.style args={#1#2}{qs/sc-#1/.try, node contents={#2}}? if you want the spacing, just use\phantom{#2}or whatever.tikzcommands? I would think you would want a single environment. then you could annotate by adding nodes for labels etc. in the usual way?l, L, L, .... Are the max-labels fixed? Shouldn't they move if you change the input?