
ここからのボックス チャプター スタイルが気に入っています。http://hstuart.dk/2007/05/21/styling-the-chapter/
このスタイルに基づいた MWE は次のとおりです。
\documentclass{memoir}
\usepackage{tikz, blindtext}
\makechapterstyle{box}{
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\renewcommand*{\printchapternum}{
\flushright
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
\end{tikzpicture}
}
\renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
\renewcommand*{\printchaptertitle}[1]{\flushright\chaptitlefont##1}
}
\chapterstyle{box}
\begin{document}
\chapter{Fancy chapter with TikZ}
\blindtext
\end{document}
ここで、1 と 2 で示されている空白の一部 (つまり、ボックスの上と下ですが、ほとんどはボックスの上) を削除したいと思います。もちろん、少しの空白は必要ですが、章の見出しに多くのスペースを占有させたくないので、空白は小さくする必要があります。これを実現する方法について何かアイデアはありますか?
ボーナス質問: クラスを使用できるようにしながら、すべてを実行することは可能ですか(クラスによって後でreport
どのような不利益が生じる可能性があるかはわかりません)?memoir
前もって感謝します。
答え1
そこにいますよ。
\documentclass{report}
\usepackage{tikz, blindtext,showframe} %% blindtext,showframe just for demo
\usepackage{titlesec}
\newcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
\newcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
\newcommand{\mybox}{%
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white,font=\chapnumfont] (1cm,1cm) node {\thechapter};
\end{tikzpicture}%
}
\titleformat{\chapter}[display]
{}{\filleft\mybox}{20pt}{\filleft\chaptitlefont}
\titlespacing*{\chapter} {0pt}{0pt}{0pt}
\begin{document}
\chapter{Fancy chapter with TikZ}
\blindtext
\end{document}
\titlespacing*{\chapter} {0pt}{0pt}{0pt}
デフォルトで設定されている値を調整し\titlespacing*{\chapter} {0pt}{50pt}{40pt}
、すべてゼロにしました。
in 20pt
in...\mybox}{20pt}...
は\titleformat
章番号とタイトルの間の垂直スペースです。必要に応じて調整してください。
答え2
以下の特定のパラメータを設定しますmemoir
:
\documentclass{memoir}
\usepackage{tikz, blindtext,showframe}
\makechapterstyle{box}{%
\setlength{\beforechapskip}{0pt}% was 50pt
\setlength{\midchapskip}{20pt}%
\setlength{\afterchapskip}{20pt}% was 40pt
\renewcommand*{\printchaptername}{}%
\renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}%
\renewcommand*{\printchapternum}{%
\flushright
\begin{tikzpicture}
\draw[fill,color=black] (0,0) rectangle (2cm,2cm);
\draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
\end{tikzpicture}%
}%
\renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}%
\renewcommand*{\printchaptertitle}[1]{\flushright\chaptitlefont##1}%
}
\chapterstyle{box}
\begin{document}
\chapter{Fancy chapter with TikZ}
\blindtext
\end{document}
showframe
以前は、さまざまなページ部分の境界ボックスを明確にしていました。