I'm using Koma and have got my section heading numbers set in the margin of the page. I have also got a coloured underline for the section headings. I want, if possible, the underline for the section headings to extend to include the number, i.e. to extend into the margin enough to start where the section number itself starts.
As a bonus, at the moment my section numbers appear at varying distances into the margin - they are in the margin just enough to fit that number. I would prefer to set them at a constant amount left of the margin, so that the left-hand side of each number lines up.
MWE:
\PassOptionsToPackage{svgnames,table,dvipsnames}{xcolor}
\documentclass[a4paper,10pt,oneside,DIV=9]{scrartcl}
% Packages
\usepackage{scrlayer-scrpage}
\usepackage{xcolor} % showframe loads this
\usepackage[normalem]{ulem}
\usepackage{hyperref}
% demo only
\usepackage{lipsum}
\usepackage{mwe}
% theme colours
\definecolor{MyThemeColour}{cmyk}{0.10,0.10,1.00,0} % personal yellow
% KOMA and general setup
\renewcommand*{\sectionformat}{%
\llap{\thesection\autodot\enskip}%
}
\renewcommand*{\subsectionformat}{%
\llap{\thesubsection\autodot\enskip}%
}
\renewcommand*{\subsubsectionformat}{%
\llap{\thesubsubsection\autodot\enskip}%
}
% underline section headings
\makeatletter
\renewcommand{\sectionlinesformat}[4]{%
\@hangfrom{\hskip #2\expandafter\headuline\expandafter{#3}}%
{#4}%
}
\makeatother
\newcommand\headuline{%
\bgroup\markoverwith{\textcolor{MyThemeColour}{\rule[-0.75ex]{1pt}{1pt}}}\ULon% 2pt 2pt
}
\AtBeginDocument{\renewcommand\Sectionformat[2]{\headuline{#1}}}
% recalc the text block after all the font loading
\KOMAoptions{DIV=last}
\begin{document}
\section{Lipsum}
\blinddocument
\end{document}


