我需要将\titlerule
in 的titlesec
开始设置为位于左边距的左侧,如图所示(仅限规则,而不是标题文本)。
以下是生成图片的 MWE:
\documentclass[12pt,a4paper]{article}
\usepackage[papersize={17cm,24cm},
total={134.5mm,209mm},
inner=43.5mm,
textwidth=109mm,
marginparsep=2.5mm,
marginparwidth=23mm]{geometry}
\usepackage{titlesec}
\titleformat{\section}%
{\raggedright\bfseries\uppercase}%
{\thesection.}{.5em}{}[{\titlerule[0.5pt]}]
\titlespacing*{\section}{0pt}{6mm}{2.5mm}
\titleformat{\subsection}%
{\titlerule\vspace{5pt}\raggedright\bfseries}%
{\thesubsection.}{.5em}{}
\titlespacing*{\subsection}{0pt}{5mm}{1mm}
\usepackage{lipsum}
\begin{document}
\section{I want the rule to include the left the margin}
\lipsum[2]
\subsection{I want the rule to include the left the margin}
\lipsum[3]
\end{document}
\hspace*{}
我之前尝试过添加\titlerule
但是出现水平模式下输入不正确的错误。
\titleformat{\subsection}%
{\hspace*{-23mm}\rule{132mm}{1pt}\vspace{5pt}\raggedright\bfseries}%
{\thesubsection.}{.5em}{}