在 titlesec 框架中移動章節名稱?

在 titlesec 框架中移動章節名稱?

我正在用 titlesec 來製作一個包含章節名稱的框架。我不知道如何移動章節名稱(範例中的“Chapter Foo”)。

這是 MWE:

\documentclass[a4paper,book,openany,twocolumn]{memoir}
\usepackage[utf8]{inputenc}
\usepackage{lipsum} 
\usepackage{titlesec}
\titleformat{\chapter}[frame]
{\normalfont\huge\bfseries}{\thechapter}{5em}{\Huge}
\titlespacing*{\chapter}{0pt}{-40pt}{15pt}
\begin{document}
\chapter*{Chapter Foo}
\lipsum
\lipsum[3-6]
\end{document}

這就是我所擁有的:在此輸入影像描述

這就是我要的:在此輸入影像描述

我希望有人能幫忙!

答案1

正如評論中提到的,titlesec and memoir不完全兼容。您可以使用內建指令memoir輕鬆定義您的風格;一個簡單的例子(根據您的需求進行必要的調整):

\documentclass[a4paper,openany,twocolumn]{memoir}
\usepackage{lipsum}

\makeatletter
\makechapterstyle{Nordestgaard}{%
\renewcommand*{\printchaptername}{}
\renewcommand*{\printchapternum}{}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries}
\renewcommand*{\printchaptertitle}[1]{%
\fbox{%
  \begin{minipage}[b][5cm][b]{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}
  \raggedright\chaptitlefont\strut##1\par\smallskip%
  \end{minipage}}}
\setlength\afterchapskip{15pt}
\setlength\beforechapskip{-40pt}
}
\makeatother
\chapterstyle{Nordestgaard}

\begin{document}

\chapter{Test chapter}
\lipsum[1-6]

\end{document}

在此輸入影像描述

相關內容