Добавление точки после заголовка подраздела

Добавление точки после заголовка подраздела

Похожий наДобавление точки после раздела. Но я использую KOMA, поэтому не могу использовать titlesec.

Кстати, собираюсь использовать руководство по стилю APA.

МВЭ:

\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}

\usepackage{lipsum}

% --- APA Style --- %

% For spacing
\usepackage{setspace}
\doublespacing

\setlength{\parindent}{0.5in}
\usepackage{indentfirst} % Indent even the 1st paragraph after each section header.

\addtokomafont{section}{\centering}
\RedeclareSectionCommand[afterskip=-1em, indent=0.5in]{subsubsection}

% --- End of APA Style --- %

\usepackage{lipsum}

\begin{document}

\tableofcontents

\clearpage

\section{This should be centered}

\lipsum[1]

\subsection{This is same as default for KOMA}

\lipsum[2]

\subsubsection[Runin, and need a dot after this title]{Runin, and need a dot after this title.}

Without resorting to using a separate `short title` without period at the end, and a `title` with the ending period, I hope to do just:

\subsubsection{Have dot at end}

\lipsum[3]

\end{document}

решение1

Если подподразделы являются заголовками, вам необходимо переопределить их \sectioncatchphraseformat, чтобы вставить точку после текста заголовка подподраздела.

\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}
% --- APA Style --- %
\usepackage{setspace}
\doublespacing
\setlength{\parindent}{0.5in}

\RedeclareSectionCommand[beforeskip=3.5ex plus 1ex minus .2ex]{section}
\RedeclareSectionCommand[beforeskip=3.25ex plus 1ex minus .2ex]{subsection}
\RedeclareSectionCommand[afterskip=-1em, indent=\the\parindent]{subsubsection}

\makeatletter
\renewcommand{\sectionlinesformat}[4]{%
  \ifstr{#1}{section}{\centering}{}% center section titles
  \@hangfrom{\hskip #2#3}{#4}%
}
\makeatother
\renewcommand{\sectioncatchphraseformat}[4]{%
  \hskip #2#3#4%
  \ifstr{#1}{subsubsection}{.}{}% dot after subsection titles
}
% --- End of APA Style --- %

\usepackage{lipsum}% only for dummy text

\begin{document}
\tableofcontents
\clearpage
\section{This should be centered}
\lipsum[1]
\subsection{This is same as default for KOMA}
\lipsum[2]
\subsubsection{Runin, and need a dot after this title}
Without resorting to using a separate `short title` without period at the end, and a `title` with the ending period, I hope to do just:
\subsubsection{Have dot at end}
\lipsum[3]
\end{document}

\documentclass{scrbook}

\renewcommand{\thechapter}{\Roman{chapter}}

\usepackage[usedvipsnames]{xcolor}
\usepackage{romanbar}
\RedeclareSectionCommand[
  tocentrynumberformat=\def\autodot{}\textcolor{red}
]{chapter}

\usepackage{xpatch}
\xpatchcmd{\addchaptertocentry}
  {\addtocentrydefault{chapter}{#1}{#2}}
  {\ifstr{#1}{}{\addtocentrydefault{chapter}{#1}{#2}}
    {\addtocentrydefault{chapter}{\protect\Romanbar{#1}}{#2}}%
  }{}{\PatchFailed}

\usepackage{lipsum}

\begin{document}
\tableofcontents

\chapter{First Chapter}
\lipsum[2]
\chapter{Second Chapter}
\lipsum[2]
\chapter{Third Chapter}
\lipsum[2]
\end{document}

введите описание изображения здесь

Если все заголовки должны иметь точку в конце, используйте:

\renewcommand{\sectioncatchphraseformat}[4]{\hskip #2#3#4.}

Дополнительные замечания:

Не злоупотребляйте элементом шрифта sectionдля центрирования заголовков разделов. \sectionlinesformatВместо этого переопределите. Нет необходимости загружать пакет indentfirst.

решение2

Это частичное решение для всего, кроме \subsubsection(которое вы переобъявляете, поэтому и не работает). Макрос \sectionlinesformatавтоматически добавит точку.

Документацию (scrguide/scrguien) этого макроса вы найдете в разделе 21 (стр. 508 в немецком руководстве, стр. 461 в английском руководстве). Это один из макросов, который KOMA использует для настройки секционирования (вместо механизмов titlesec).

кома

\documentclass[a4paper, oneside, 12pt, parskip=half]{scrartcl}

\usepackage{lipsum}

% --- APA Style --- %

% For spacing
\usepackage{setspace}
\doublespacing

\setlength{\parindent}{0.5in}
\usepackage{indentfirst} % Indent even the 1st paragraph after each section header.

\addtokomafont{section}{\centering}
\RedeclareSectionCommand[afterskip=-1em, indent=0.5in]{subsubsection}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \@hangfrom{\hskip#2 #3}{#4.}
}
\makeatother

\begin{document}
\tableofcontents

\clearpage

\section{This should be centered}

\lipsum[1]

\subsection{This is same as default for KOMA}

\lipsum[2]

\subsubsection[Runin, and need a dot after this title]{Runin, and need a dot after this title.}

Without resorting to using a separate `short title` without period at the end, and a `title` with the ending period, I hope to do just:

\subsubsection{Have dot at end}

\lipsum[3]

\end{document}

Связанный контент