Q:

Placing a rule in a custom section title (scrbook)

Starting from the accepted answer of
Customizing chapter and section style (scrbook)
I did the following to get customized section titles in a scrbook
(Minimal (not) Working Example):
\documentclass[]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage{xcolor}

\newlength{\sectsquaresize}
\setlength\sectsquaresize{70pt}

\addtokomafont{section}{\fontsize{14pt}{14pt}\selectfont}

\newkomafont{sectionnumber}{\fontsize{18pt}{18pt}\color{black}}

\renewcommand\sectionformat{%
    \parbox{\sectsquaresize}{%
    \setlength\fboxsep{0pt}%
    \setlength\fboxrule{1pt}%
  \fbox{\colorbox{yellow}{%
      \parbox[m][\dimexpr \sectsquaresize -  2 \fboxrule][c]{\dimexpr \sectsquaresize - 2 \fboxrule}%
                {\centering{\usekomafont{sectionnumber}{\thesection\autodot}}}}}}%
    \quad%  
    }

\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \@hangfrom{\hspace*{#2}#3}{#4}%
  \ifstr{#1}{section}{%
    \par\nobreak%
    \ifstr{#3}{}{%
      \rule[\dp\strutbox]{\textwidth}{1pt}}{%
      \hspace*{\sectsquaresize}\rule[\dp\strutbox]{\dimexpr\textwidth-\sectsquaresize}{1pt}}%
  }{}%
}
\makeatother

\newcommand{\sectionproc}[1]{\parbox[m][\sectsquaresize][c]{\dimexpr\textwidth - \sectsquaresize - 17pt}{\raggedright #1}}
\newcommand{\ltdis}[1]{#1}

\setlength{\parindent}{0pt}

\begin{document}

\chapter{Erkrankungen des Bewegungsapparats}

\section[Rheumatoide Arthritis]{\sectionproc{Rheumatoide Arthritis\newline\ltdis{Arthritis rheumatoides}}}

\blindtext

\section[Rheumatismus]{\sectionproc{Rheumatismus\newline\ltdis{Rheumatismus}}}

\blindtext

\section[Arthrose mit besonderer Deformation der Gelenke]{\sectionproc{Arthrose mit besonderer Deformation der Gelenke\newline\ltdis{Arthrosis deformans, spondylosis deformans}}}

\blindtext

\section[Händezittern]{\sectionproc{Händezittern\newline\ltdis{Tendovaginitis}}}

\blindtext

\end{document}

In the output, the horizontal \rule, which starts horizontally after the framed yellow square and ends at the textline end, is vertically not aligned to the lower black frame line of the yellow square (as I wished it should be).

I tried to introduce \vspace*{[a negative value]} after \par\nobreak to remedy this, but could not find a suitable expression which works in all cases.
\renewcommand\sectionlinesformat[4]{%
  \@hangfrom{\hspace*{#2}#3}{#4}%
  \ifstr{#1}{section}{%
    \par\nobreak%
    \ifstr{#3}{}{%
      \rule[\dp\strutbox]{\textwidth}{1pt}}{%
      \hspace*{\sectsquaresize}\rule[\dp\strutbox]{\dimexpr\textwidth-\sectsquaresize}{1pt}}%
  }{}%
}

What could I do to get the \rule aligned with the lower black frame line of the yellow square?

A:

Maybe the following does what you want:
\documentclass{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[german]{babel}
\usepackage{etoolbox}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{lmodern}% scalable font

\newlength{\sectsquaresize}
\setlength\sectsquaresize{70pt}

\addtokomafont{section}{\fontsize{14pt}{17pt}\selectfont}%<- changed
\newkomafont{sectionnumber}{\fontsize{18pt}{18pt}\selectfont\color{black}}%<- changed

\renewcommand\sectionformat{%
  \setlength\fboxsep{0pt}%
  \setlength\fboxrule{1pt}%
  \fcolorbox{black}{yellow}{%
    \parbox[m][\dimexpr \sectsquaresize - 2 \fboxrule][c]{\dimexpr \sectsquaresize - 2 \fboxrule}%
       {\centering{\usekomafont{sectionnumber}{\thesection\autodot}}}}%
  \quad%
}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{section}{%
    \raisebox{\dimexpr\depth+\dp\strutbox\relax}{%
      \makebox[0pt][l]{\@hangfrom{\hspace*{#2}#3}{%
        \parbox[m][\sectsquaresize][c]{\dimexpr\textwidth - \sectsquaresize - 17pt}{\raggedsection #4}%
      }}%
    }%
    \ifstr{#3}{}{%
      \rule[\dp\strutbox]{\textwidth}{1pt}%
    }{%
      \hspace*{\sectsquaresize}\rule[\dp\strutbox]{\dimexpr\textwidth-\sectsquaresize}{1pt}%
    }%
  }{%
    \@hangfrom{\hspace*{#2}#3}{#4}% original definition for other section levels
  }
}
\makeatother

\newcommand{\ltdis}[1]{#1}

\setlength{\parindent}{0pt}
\begin{document}
\chapter{Erkrankungen des Bewegungsapparats}
\section[Rheumatoide Arthritis]{Rheumatoide Arthritis\newline\ltdis{Arthritis rheumatoides}}
\blindtext
\section[Rheumatismus]{Rheumatismus\newline\ltdis{Rheumatismus}}
\blindtext
\section[Arthrose mit besonderer Deformation der Gelenke]{Arthrose mit besonderer Deformation der Gelenke\newline\ltdis{Arthrosis deformans, spondylosis deformans}}
\blindtext
\section[Händezittern]{Händezittern\newline\ltdis{Tendovaginitis}}
\blindtext
\end{document}

Result:

