
Me gusta el estilo del capítulo del cuadro de aquí:http://hstuart.dk/2007/05/21/styling-the-chapter/
Aquí hay un MWE basado en este 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}
Ahora me gustaría eliminar algunos de los espacios en blanco indicados por 1 y 2 (por encima y por debajo del cuadro, pero principalmente encima del cuadro). Por supuesto, debería haber un poco de espacio en blanco, pero no quiero que los títulos de los capítulos ocupen mucho espacio, por lo que debería ser más bien pequeño. ¿Alguna idea sobre cómo puedo lograr esto?
Pregunta adicional: ¿es posible hacer todo mientras me permite usar la report
clase (no sé qué posibles desventajas memoir
podría traerme la clase más adelante)?
Gracias de antemano.
Respuesta1
Ahí tienes.
\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 los valores \titlespacing*{\chapter} {0pt}{0pt}{0pt}
que están \titlespacing*{\chapter} {0pt}{50pt}{40pt}
por defecto, los he hecho todos cero.
El 20pt
in ...\mybox}{20pt}...
in \titleformat
es el espacio vertical entre el número del capítulo y el título. Ajusta si quieres.
Respuesta2
Quiere establecer los 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}
Solía showframe
hacer evidentes los cuadros delimitadores de las distintas partes de la página.