# How to use tkiz point from two different nodes on separate axis?

I know I need to use the x from the counter node and the y from the rectangle node, but so far the right syntax has eluded me.

Green indicates what I'm trying to fill, and red indicates the where the line should extend to.

\documentclass{scrbook}
\usepackage[compact,explicit,calcwidth]{titlesec}
\usepackage{tikz,lipsum}
\usetikzlibrary{calc}

\setkomafont{section}{\normalfont\bfseries}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newlength\titlemarginwidth
\setlength\titlemarginwidth{54pt}

\newcommand\boxedsection[1]{{%
\usekomafont{sectioning}\usekomafont{section}%
\begin{tikzpicture}[x=1pt,y=1pt,inner sep=0, inner ysep=0.7ex]
\node[anchor=base west,text width=\titlemarginwidth-\columnsep,color=white] at (0,0) (counter) {\hspace{1ex}\thesection};
\node[anchor=base west,text width=\textwidth] at ($(counter.base east)+(\columnsep,0)$) (rectangle) {#1};
\begin{pgfonlayer}{background}
\fill[color=black] let \p1=(counter.north), \p2=(counter.north) in (0,{max(\y1,\y2)}) rectangle (counter.south east);
\draw[black,thick] let \p1=(counter.north), \p2=(counter.north) in (0,{max(\y1,\y2)}) -- (rectangle.north east);
\draw[black,thick] (rectangle.south west) -- (rectangle.south east);
\end{pgfonlayer}
\end{tikzpicture}
}}

\titlespacing{\section}{-\titlemarginwidth}{1em}{0em}
\titleformat{\section}[block]
{}%
{}{0pt}{\boxedsection{#1}}

\begin{document}
\chapter{Testing One Two Three!}
\section{Extremely long section title that is absolutely absurd and obnoxious that goes on forever and ever and ever and ever!}
\lipsum[1]
\end{document}


I switched to tikz after having trouble with spacing using just titlesec rules and boxes.

-
(counter|-rectangle) –  JLDiaz Mar 7 '13 at 23:34

You can use the perpendicular coordinate system (refer to the PGF documenation (pp. 130-131)); in fact, you don't need here the let syntax at all. I also suppressed some redundant code from your example:

\documentclass{scrbook}
\usepackage[compact,explicit,calcwidth]{titlesec}
\usepackage{tikz,lipsum}
\usetikzlibrary{calc}

\setkomafont{section}{\normalfont\bfseries}

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newlength\titlemarginwidth
\setlength\titlemarginwidth{54pt}

\newcommand\boxedsection[1]{{%
\usekomafont{sectioning}\usekomafont{section}%
\begin{tikzpicture}[x=1pt,y=1pt,inner sep=0, inner ysep=0.7ex]
\node[anchor=base west,text width=\titlemarginwidth-\columnsep,color=white] at (0,0) (counter) {\hspace{1ex}\thesection};
\node[anchor=base west,text width=\textwidth] at ($(counter.base east)+(\columnsep,0)$) (rectangle) {#1};
\begin{pgfonlayer}{background}
\fill[color=black] (0,0|-counter.north) rectangle (counter.south east|-rectangle.south east);
\draw[black,thick] (0,0|-counter.north) -- (rectangle.north east);
\draw[black,thick] (0,0|-rectangle.south west) -- (rectangle.south east);
\end{pgfonlayer}
\end{tikzpicture}
}}

\titlespacing{\section}{-\titlemarginwidth}{1em}{0em}
\titleformat{\section}[block]
{}%
{}{0pt}{\boxedsection{#1}}

\begin{document}
\chapter{Testing One Two Three!}
\section{Extremely long section title that is absolutely absurd and obnoxious that goes on forever and ever and ever and ever!}
\lipsum[1]
\end{document}


-