我正在尝试用这段代码来获得一个漂亮的章节标题:(http://texnorte.blogspot.com/2012/06/styling-my-sectionchapter.html),但是我无法将章节标题放在行上而不是旁边。它应该在页面的右侧,就像链接中那样。有人能帮我吗 :)
\titleformat{\chapter}[display]
{\normalfont\scshape\Huge}
{\hspace*{-70pt}\thechapter.~}
{-15pt}
{\hspace*{-110pt}\rule{\dimexpr\textwidth+80pt\relax}{3pt}\Huge}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\scshape\Huge}
{\hspace*{-70pt}}
{-15pt}
{\hspace*{-110pt}\rule{\dimexpr\textwidth+80pt\relax}{3pt}\Huge}
\titlespacing*{\chapter}{0pt}{0pt}{30pt}
答案1
不确定我是否已经理解了你想要什么,但我建议一些这样的(使用默认hang
样式):
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{erewhon}
\usepackage[svgnames]{xcolor}
\usepackage{titlesec}
\titleformat{\chapter}
{\normalfont\scshape\Huge}
{\hspace*{-70pt}\thechapter.~}
{15pt}
{\Huge}[\vskip -1.5ex\hspace*{-110pt}\color{IndianRed}\rule{\dimexpr\textwidth+80pt\relax}{3pt}]
\titleformat{name=\chapter,numberless}
{\normalfont\scshape\Huge}
{\hspace*{-70pt}}
{-15pt}
{\Huge}[\vskip -1.5ex\hspace*{-110pt}\color{IndianRed}\rule{\dimexpr\textwidth+80pt\relax}{3pt}]
\titlespacing*{\chapter}{0pt}{0pt}{30pt}
\begin{document}
\chapter{Method}
\chapter*{References}
\end{document}