将章节标题移动到页面上的特定位置

将章节标题移动到页面上的特定位置

我想将所有章节标题(此处为 Aim)移到包含章节编号的黑框下方。请参阅下图以直观地了解问题。

\documentclass[oneside,10pt,oldfontcommands,standalone]{memoir} 
\usepackage[T1]{fontenc}

\usepackage{amsmath}
\usepackage[explicit]{titlesec}
\usepackage{siunitx}
\usepackage{tikz}
\usepackage{lipsum}
\newcommand{\chaptercolor}{black}

\titleformat{\chapter}[display]
{\normalfont\filcenter}
{\tikz[remember picture,overlay]
    {\node[fill=\chaptercolor,
        font=\sffamily\fontsize{50}{40}\bf\selectfont\color{white},anchor=north east, 
        minimum width=3cm, 
        minimum height=3cm] 
        at (7,0) 
        (numb) {\thechapter};
        \node[rotate=90,
        anchor=south,
        inner sep=0pt,
        font=\Huge\sffamily]
        at (numb.west) {\SPREAD\chaptertitlename};
}}
{20pt}
{\Huge\bfseries\color{\chaptercolor}#1}%

\ExplSyntaxOn
\NewDocumentCommand{\SPREAD}{m}
{% full expand the argument
    \vincent_spread:f { #1 }
}
\cs_new_protected:Npn \vincent_spread:n #1
{% with \tl_map_inline:nn we insert \hfil between letters; a final \unskip kills the last \hfil
    \makebox[3cm][s]{\tl_map_inline:nn { #1 } { ##1 \hfil } \unskip}
}
\cs_generate_variant:Nn \vincent_spread:n { f }
\ExplSyntaxOff

\begin{document}
    \chapter{Aim}
    \vspace*{2cm}
    \lipsum
\end{document}

在此处输入图片描述

答案1

只需修改您的 titleformat 命令即可

\titleformat{\chapter}[display]
{\normalfont\filcenter}
{\tikz[remember picture,overlay,baseline=(numb.base)]
    {\node[fill=\chaptercolor,
        font=\sffamily\fontsize{50}{40}\bf\selectfont\color{white},anchor=north east, 
        minimum width=3cm, 
        minimum height=3cm] 
        at (7,0) 
        (numb) {\thechapter};
        \node[rotate=90,
        anchor=south,
        inner sep=0pt,
        font=\Huge\sffamily]
        at (numb.west) {\SPREAD\chaptertitlename};
}}
{0pt} %<- increase
{\Huge\bfseries\color{\chaptercolor}#1}%

如果你(确实)想将“Aim”进一步向下移动,你可以0pt在倒数第二行增加一个更大的值。如果你想保持与测试的距离不变,请使用

\titleformat{\chapter}[display]
{\normalfont\filcenter}
{\tikz[remember picture,overlay,baseline=(numb.base)]
    {\node[fill=\chaptercolor,
        font=\sffamily\fontsize{50}{40}\bf\selectfont\color{white},anchor=north east, 
        minimum width=3cm, 
        minimum height=3cm] 
        at (7,0) 
        (numb) {\thechapter};
        \node[rotate=90,
        anchor=south,
        inner sep=0pt,
        font=\Huge\sffamily]
        at (numb.west) {\SPREAD\chaptertitlename};
}}
{1cm} %<- increase
{\Huge\bfseries\color{\chaptercolor}#1\vspace*{-1cm}}% <- add neg vspace

相关内容