我的代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\begin{document}
% Set Section Title Formatting %
\titleformat{\section}{\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}]
\titleformat{\subsection}{\bfseries}{\thesubsection}{1em}{}[]
\titleformat{\subsubsection}{\bfseries\itshape}{\thesubsubsection}{1em}{}[]
\titleformat{\paragraph}{\itshape}{\theparagraph)}{1em}{}[]
\setcounter{secnumdepth}{4}
\section{Introduction}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph}
\end{document}
输出:
期望输出:
答案1
如果仔细查看代码,会发现后面有一个括号\theparagraph
。如果将其删除,则会得到所需的输出。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\begin{document}
% Set Section Title Formatting %
\titleformat{\section}{\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}]
\titleformat{\subsection}{\bfseries}{\thesubsection}{1em}{}[]
\titleformat{\subsubsection}{\bfseries\itshape}{\thesubsubsection}{1em}{}[]
\titleformat{\paragraph}{\itshape}{\theparagraph}{1em}{}[]
\setcounter{secnumdepth}{4}
\section{Introduction}
\subsection{Subsection}
\subsubsection{Subsubsection}
\paragraph{Paragraph}
\end{document}