在小節標題後面加入句點/點

在小節標題後面加入句點/點

如同在部分後面加入句點。但我用的是 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將自動附加點。

您可以在第 21 節(德語指南第 508 頁,英語指南第 461 頁)中找到該巨集的文檔 (scrguide/scrguien)。它是 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}

相關內容