# Delimiter in custom section header

I've defined a custom section command by \DeclareNewSectionCommand and given it a custom outfit by \renewcommand\thecustomsection{Custom Section \arabic{customsection}. Using \customsection{Blah} the result of course looks like this:

Custom Section 1 Blah


However what I want it to look like is:

Custom Section 1 - Blah


with a custom delimiter in between.

I've achieved this already by adding the delimiter to the \renewcommand line but that way the delimiter also appears in \autoref references to such a custom section like:

In \autoref{csec:blah} lorem ipsum\dots


which results in:

In Custom Section 1 - lorem ipsum...


So how can I add a delimiter between the common header part "Custom Section X" and the actual section title without it appearing in refs and other similar cases where only the common part of the section header is used?

### MWE:

\documentclass{scrartcl}
\usepackage{hyperref}
\setlength{\parindent}{0mm}
\setlength{\parskip}{6mm}

% Declare the new section command customsection
\DeclareNewSectionCommand[
afterskip=1.5ex plus .2ex,
beforeskip=-3.25ex plus -1ex minus -.2ex,
indent=0pt,
level=2,
font=\usekomafont{subsection},
tocindent=1.5em,
tocnumwidth=2.3em,
counterwithin=section,
style=section]{customsection}

% Here I add the hyphen as a custom delimiter
% between the prefix and the title.
% This is obviously the wrong way to do it.
\renewcommand{\thecustomsection}{Custom Section \arabic{customsection} - }

\begin{document}

\section{Hello}
\customsection{Blah}\label{csec:blah}
% What it looks like:
% Custom Section 1 -  Blah

% What it should look like:
% Custom Section 1 - Blah

% As you can see, the delimiter is also
% not centered between the prefix and
% the actual section title.

\customsection{Blubb}\label{csec:blubb}
In \autoref{csec:blah} lorem ipsum...
% What it looks like:
% In Custom Section 1 -  lorem ipsum...

% What it should look like:
% In Custom Section 1 lorem ipsum...

\end{document}

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Skillmon Apr 17 '18 at 7:24
• Alright, give me a second – Hendrik Wiese Apr 17 '18 at 8:03

Change the definition of \customsectionformat which is used while creating the headings.

\documentclass[]{scrartcl}

\usepackage[]{hyperref}
% Declare the new section command customsection
\DeclareNewSectionCommand[
afterskip=1.5ex plus .2ex,
beforeskip=-3.25ex plus -1ex minus -.2ex,
indent=0pt,
level=2,
font=\usekomafont{subsection},
tocindent=1.5em,
tocnumwidth=2.3em,
counterwithin=section,
style=section]{customsection}

\renewcommand*\thecustomsection{Custom Section~\arabic{customsection}}
\renewcommand*\customsectionformat{\thecustomsection\ -\ }

\begin{document}
\section{Hello}
\customsection{Blah}\label{csec:blah}
% What it looks like:
% Custom Section 1 -  Blah

% What it should look like:
% Custom Section 1 - Blah

% As you can see, the delimiter is also
% not centered between the prefix and
% the actual section title.

\customsection{Blubb}\label{csec:blubb}
In \autoref{csec:blah} lorem ipsum...
% What it looks like:
% In Custom Section 1 -  lorem ipsum...

% What it should look like:
% In Custom Section 1 lorem ipsum...

\end{document}