我正在努力獲取如下圖所示的章節部分。
到目前為止,我已經得到了這個,它基本上不能產生我想要的切片
我的程式碼是這樣的;
\usepackage{titlesec,geometry,lipsum}
\usepackage[export]{adjustbox}
\geometry{a4paper, portrait, margin=1in}
%Chapter Headers
\titleformat{\chapter}[display]
{\normalfont\Large\raggedleft}
{\adjustbox{lap=.7\width}{\MakeUppercase{\chaptertitlename}%
\resizebox{!}{1.5cm}{\thechapter} \rule{7cm}{1.5cm}}}
{10pt}{\huge\bfseries\raggedright}
\titlespacing*{\chapter}{0pt}{30pt}{20pt}
\begin{document}
\chapter{Introduction}
\end{document}
答案1
一種可能的方式:
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{titlesec,geometry}
\geometry{a4paper, portrait, margin=1in}
\titleformat{\chapter}[display]
{\huge}
{\filleft\textsc{\large\chaptertitlename}%
\makebox[0pt]{\hspace{2em}\fontsize{40}{48}\selectfont\sffamily\bfseries\thechapter}}
{1ex}
{\titlerule \vspace{1ex}%
\filleft\bfseries\sffamily}
\begin{document}
\chapter{Introduction}
\end{document}
輸出:
答案2
通過一些 tikz 幫助來覆蓋:
\documentclass{book}
\usepackage{titlesec,geometry,lipsum}
\usepackage[export]{adjustbox}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand{\chaptikzmark}{\begin{tikzpicture}[remember picture,overlay] \coordinate (Chap\arabic{mychapter});\end{tikzpicture}}
\newcounter{mychapter}
\newcommand\AddNumber{\begin{tikzpicture}[remember picture,overlay,baseline=0] \node[shift={(6mm,0.55cm)}] at (Chap\arabic{mychapter}) {\resizebox{1cm}{!}{\bfseries\arabic{chapter}}};\end{tikzpicture}}
\geometry{a4paper, portrait, margin=1in}
%Chapter Headers
\titleformat{\chapter}[display]
{\normalfont\Large\raggedleft}
{\MakeUppercase{\chaptertitlename}%
\refstepcounter{mychapter}\chaptikzmark}
{10pt}{\raggedleft\rule{\textwidth}{0.35mm}\linebreak\huge\bfseries\AddNumber}
\titlespacing*{\chapter}{0pt}{30pt}{20pt}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\Large\raggedleft}
{\MakeUppercase{\chaptertitlename}%
}
{10pt}{\raggedleft\rule{\textwidth}{0.35mm}\linebreak\huge\bfseries}
\begin{document}
\chapter{Introduction}
\chapter*{Test}
\chapter{A new chapter}
\end{document}