
Я пытался включить маркер на полях для всех разделов документа, но команды 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
Вы могли бы переопределить \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
Из моего старого ответа с переопределением раздела (можно улучшить, если это соответствует вашим потребностям, поскольку это может вызвать проблемы с «разделом оглавления», если таковые имеются и т. д.):
\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}
Выход:
Подождите лучших ответов, потому что я на самом деле не использую этот documentclass