Como desenhar uma linha vertical com exatamente a altura de uma parbox ao lado dela
Estou tentando criar pequenas seções para um cv onde o nome da seção e uma linha vertical devem estar ao lado do conteúdo. O nome da seção deve ser centralizado e a linha vertical deve ter exatamente a altura do conteúdo. Esta é a saída desejada:

Agora, com meu código, não sei como definir a altura da linha vertical para obter exatamente a altura do \parbox
. É por isso que, para demonstração, configurei para 1 cm. Alguém sabe como obter a saída desejada com pequenas modificações no meu código ou uma maneira ainda melhor de conseguir isso?
\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
\newcommand{\customsection}[2]{
\begin{minipage}{0.05\textwidth}
\rotatebox[origin=c]{90}{#1}
\hspace{0.01cm}
\begin{tikzpicture}
\fill [bottom color=red, top color=blue] (0cm, 0cm) rectangle (-0.05cm, 1cm);
\end{tikzpicture}
\end{minipage}
\parbox[c]{0.85\textwidth}{
#2
}
}
\begin{document}
\customsection{TEST}{\lorem \\ \lorem \\ \lorem}
\end{document}
Também tentei acessar a altura de parbox, o que não funcionou para mim: Altura de acesso de uma \ parbox
Desde já, obrigado.
Minha saída:

Respostas
Que tal o seguinte código? A documentação é fornecida no código como comentários.
\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand{\lorem}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.}
% Define owmal's box to store the \parbox
\newsavebox\owmalsbox
% Notice where `%' are added to suppress end-of-line spaces!
\newcommand{\customsection}[2]{%
% First we save \parbox into \owmalsbox.
% We also use \strut both at the beginning and at the end,
% and this will ensure that the first line and the last line
% have the same height (in most cases).
\sbox\owmalsbox{%
\parbox[c]{0.85\textwidth}{%
\strut#2\strut
}%
}%
% The total height of the \parbox is now available as
% \the\ht\owmalsbox+\the\dp\owmalsbox, so we can put our
% side-way text at (\the\ht\owmalsbox+\the\dp\owmalsbox)/2,
% and draw our rectangle accordingly. The minipage has the
% optional argument `c' to go with `\parbox[c]...' above.
% Notice again the use of \strut in the side-way text.
\begin{minipage}[c]{0.05\textwidth}
\begin{tikzpicture}
\node [rotate=90, above] at
(-0.05cm, {(\the\ht\owmalsbox+\the\dp\owmalsbox)/2})
{\strut#1};
\fill [bottom color=red, top color=blue]
(0cm, 0cm)
rectangle
(-0.05cm, \the\ht\owmalsbox+\the\dp\owmalsbox);
\end{tikzpicture}%
\end{minipage}%
% The following additional space depends on how you setup
% the minipage (it is 0.05\textwidth wide for now).
% Adjust these if necessary.
\hspace{0.5cm}%
% Finally we typeset \owmalsbox by releasing its content
% (and also destroy its content).
\unhbox\owmalsbox
}
\begin{document}
\customsection{TEST}{\lorem \\ \lorem \\ \lorem}
\end{document}
