2

I was trying to include a bullet in the margin for all sections in a document, but KOMA commands only seem to influence numbered sections, not the unnumbered ones. Am I missing something here? (All sections will be unnumbered in the end, with just a bullet. )

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}

\renewcommand*{\sectionformat}{%
\makebox[0pt][r]{\textcolor{gray}{\textbullet}~}}

\begin{document}


\section{Section}

\section*{Unnumbered section}

\end{document}

1]

2 Answers 2

2

You could redefine \sectionlinesformat:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{section}{\makebox[0pt][r]{\normalfont\textcolor{gray}{\textbullet}~}}%
  \@hangfrom{\hskip #2#3}{#4}% original definition
}
\makeatother

\usepackage{lipsum}% only for dummy text

\begin{document}
\section{Section}
\lipsum[1]
\addsec*{Unnumbered section}
\lipsum[2]
\end{document}

enter image description here

Or you could this command:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}

\usepackage{xpatch}
\xpretocmd\sectionlinesformat
  {\ifstr{#1}{section}{\makebox[0pt][r]{\normalfont\textcolor{gray}{\textbullet}~}}}
  {}{\PatchFailed}

\usepackage{lipsum}% only for dummy text

\begin{document}
\section{Section}
\lipsum[1]
\addsec*{Unnumbered section}
\lipsum[2]
\end{document}

The result is the same as above.

0

From an old answer of mine with section redefinition (Can be improved if fits your needs because it may cause problems to the "toc section" if any etc):

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}

%\renewcommand*{\sectionformat}{%
%\makebox[0pt][r]{\textcolor{gray}{\textbullet}~}}
\let\oldsection\section
\makeatletter
\def\section{%
\@ifstar{\def\thesection{~}\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\setkomafont{section}{\sectionformat}%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldsection*{\makebox[0pt][r]{\textcolor{gray}{\textbullet}~}#2}%
}
\def\@StarredWithout#1{
\oldsection*{\makebox[0pt][r]{\textcolor{gray}{\textbullet}~}#1}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldsection[#1]{\textcolor{gray}{\textbullet}~#2}%
}
\def\@nonStarredWithout#1{%
\oldsection{\textcolor{gray}{\textbullet}~#1}%
}
\makeatother

\begin{document}


\section{Section}

\section*{Unnumbered section}

\end{document}

Output:

enter image description here

Wait for better answers because I don't really use this documentclass

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy