Oktober 11th, 2008 by Stefan Kottwitz
A question on LaTeX-Community.org inspired me to try pgf/TikZ together with titlesec to produce fancy chapter headings. The result is this small compilable demonstration example:
\documentclass[svgnames]{report}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
\titleformat{\chapter}
{\gdef\chapterlabel{}
\normalfont\sffamily\Huge\bfseries\scshape}
{\gdef\chapterlabel{\thechapter\ }}{0pt}
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-3cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=LightSkyBlue] (0,0) rectangle
(\paperwidth,3cm);
\node[anchor=east,xshift=.9\paperwidth,rectangle,
rounded corners=20pt,inner sep=11pt,
fill=MidnightBlue]
{\color{white}\chapterlabel#1};
\end{tikzpicture}
};
\end{tikzpicture}
}
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}
\begin{document}
\tableofcontents
\chapter{Introduction}
Text
\chapter{Main}
\section{Section}
Text
\begin{thebibliography}{99}
\bibitem{Test} test reference
\end{thebibliography}
\end{document}
Screenshot:
See also pdf output of this test & demo file.
Later question on TeX.SX: Fancy chapter headings - perhaps you have an addition to that?
Category: pgf/TikZ, Sectioning, Layout |
77 Comments »
Juni 17th, 2008 by Stefan Kottwitz
Some packages like nomencl, glossary and environments like thebibliography in standard LaTeX classes use the starred sectioning forms \chapter* and \section*. Even if they provide an option to let them added to the table of contents it may be required to use numbered sectioning. In that case you could look at the corresponding source code (article.cls, nomencl.sty, glossary.sty, …) and redefine thebibliography by \renewenvironment or redefine thenomenclature of the nomencl package etc.
Here I will show a way without redefining certain internal environments. I will use the TeX commands \def and \let to temporarily change the meaning of \section:
\let\stdsection\section
\def\section*#1{\stdsection{#1}}
\printnomenclature
% \printglossary
\let\section\stdsection
If you are interested in testing it by yourself you can find complete examples here.
This topic was discussed on mrunix.de and in the LaTeX Community Forum.
Category: Sectioning, plain TeX |
No Comments »
April 13th, 2008 by Stefan Kottwitz
Some LaTeX tutorials and at least one wellknown online reference manual explain the declaration of an appendix by an environment, they recommend to write: \begin{appendix} … \end{appendix}. Though this will be compiled without error it actually is not functioning like we expect of an environment. Everything that follows \end{appendix} will also be treated as part of the appendix!
The correct usage is:
This command is defined by the standard classes by \newcommand, not by \newenvironment, there’s no \endappendix. For example here’s the original code of book.cls:
\newcommand\appendix{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{\appendixname}%
\gdef\thechapter{\@Alph\c@chapter}}
If you want to end the appendix and add further chapters or sections like list of figures etc. you would have to undo the changes made by \appendix or use just a common chapter or section labeled as appendix.
The appendix package provides more facilities for typesetting appendices and even allows subappendices.
This topic was discussed in the LaTeX Community Forum and on Matheplanet.
Category: Sectioning |
1 Comment »