
Eu gosto do estilo do capítulo da caixa daqui:http://hstuart.dk/2007/05/21/styling-the-chapter/
Aqui está um MWE baseado neste estilo:
\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}
Agora eu gostaria de eliminar alguns dos espaços em branco indicados por 1 e 2 (acima e abaixo da caixa, mas principalmente acima da caixa). É claro que deve haver um pouco de espaço em branco, mas não quero que os títulos dos capítulos ocupem muito espaço, por isso devem ser bem pequenos. Alguma idéia de como posso conseguir isso?
Pergunta bônus: é possível fazer tudo enquanto me permite usar a report
classe (não sei quais possíveis desvantagens a memoir
classe pode me trazer mais tarde)?
Desde já, obrigado.
Responder1
Aí está você.
\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}
Ajuste os valores \titlespacing*{\chapter} {0pt}{0pt}{0pt}
que são \titlespacing*{\chapter} {0pt}{50pt}{40pt}
por padrão, zerei todos eles.
O 20pt
in ...\mybox}{20pt}...
in \titleformat
é o espaço vertical entre o número do capítulo e o título. Ajuste se quiser.
Responder2
Você deseja definir os parâmetros específicos de 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}
Eu costumava showframe
deixar aparentes as caixas delimitadoras das várias partes da página.