如何在標題和目錄中的 \section 編號後面新增點,而不在 \ref 指令新增點

如何在標題和目錄中的 \section 編號後面新增點,而不在 \ref 指令新增點

我需要在編號後面用點列印\section( \subsection, ...) 標題。\subsubsection

例子:

  1. 我的頭銜

為此,我使用:

\renewcommand\thesection{\normalfont \arabic{section}.}

\renewcommand\thesubsection{\thesection\arabic{subsection}.}

\renewcommand\thesubsubsection{\thesubsection\arabic{subsubsection}.}

\renewcommand\theparagraph{\thesubsubsection\arabic{paragraph}.}

但這種方法也會在\ref{}指令中加入額外的點。所以編碼“查看部分\ref{section:label}”。產生字串“Look at section 3..”

有沒有辦法只在標題和目錄中添加點,而不在參考文獻中添加點?

答案1

以下是如何使用titlesec/titletoc.標籤後面的點是由 增加的\titleformat,而不是由 增加的\thesection。至於目錄中的點,它是titletoc中的一個選項。此外,我使用cleveref交叉引用來更簡單地編寫。

\documentclass[12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{heuristica}
\usepackage{lipsum}
\usepackage{titlesec}
\usepackage[dotinlabels]{titletoc}
\titleformat{\section}[hang]{\bfseries\large}{Section \thesection.}{0.4em}{}
\titlespacing*{\section}{0pt}{2\baselineskip}{2\baselineskip}
\dottedcontents{section}[3.8em]{}{2.3em}{1pc}
\usepackage{cleveref}

\begin{document}

\tableofcontents

\section{Preliminaries}\label{sec:prelim}
\lipsum[1]

\section{Another section}
See \Cref{sec:prelim}.

\end{document} 

在此輸入影像描述

答案2

\usepackage{titlesec}
\titlelabel{\thetitle.\quad}

更多資訊請參見titlesec文件在第 3 頁。

相關內容