KOMA 스크립트를 사용하여 번호가 없는 섹션 제목 앞의 글머리 기호

KOMA 스크립트를 사용하여 번호가 없는 섹션 제목 앞의 글머리 기호

문서의 모든 섹션에 대한 여백에 글머리 기호를 포함하려고 했지만 KOMA 명령은 번호가 없는 섹션에는 영향을 주지 않고 번호가 있는 섹션에만 영향을 미치는 것 같습니다. 여기서 뭔가 빠졌나요? (모든 섹션은 글머리 기호만 포함하여 결국 번호가 매겨지지 않습니다.)

\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]

답변1

다음을 재정의할 수 있습니다 \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}

여기에 이미지 설명을 입력하세요

또는 다음 명령을 수행할 수 있습니다.

\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}

결과는 위와 같습니다.

답변2

섹션 재정의가 포함된 내 오래된 답변에서("toc 섹션"에 문제가 발생할 수 있으므로 필요에 맞게 개선할 수 있음):

\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}

산출:

여기에 이미지 설명을 입력하세요

나는 이 문서 클래스를 실제로 사용하지 않기 때문에 더 나은 답변을 기다리십시오.

관련 정보