TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was inspired by the article "Fancy chapter headings with TikZ" (Stefan Kottwitz many thx) and I have created the whole fancy sectioning. But what I need to do now is to import this whole code for sections and chapter into my REPORT CLASS because I dont want this code to be in my project. For example when I will start my new project and will add the \documentclass[svgnames]{report} and will begin document with \section{bla bla} so the edited sectioning in report class will be automatically applied for the \section{bla bla} command.

I am asking for some help because I have never ever played with the latex files and classes.

share|improve this question
Would it not be more convenient to put this in your own custom package? Then you could just write: \usepackage{myfancysections}. If you really want it in the class, consider cloning article.cls, but I would not suggest it. It is way less partible then putting this in your own package. – jmc Mar 27 '12 at 13:20
up vote 5 down vote accepted

For your class, I added some useful packages and options


But you can remove if you want, I added also


useful for TikZ

and finally


But you can also remove these packages. You need to save the next code in a file names myreport.cls.

\NeedsTeXFormat{LaTeX2e}[1995/12/01]% standard latex package works with this format
\ProvidesClass{myreport}% we give the name of the new class (here myreport) and we give
  % some informations about date of creation and the aim of the document 
[2012/03/27\space Version:\space 1.0\space myreport documentation class]
 % more complex We create a new class based on an existing class and we want to use the   
  options of report
\ProcessOptions\relax% this is the way to process the options, Stephan gave the good link    
 for clsguide.pdf
\LoadClass[]{report}  % add options if necessarry , we can create personal options
  % To avoid clash with xcolor,  \PassOptionsToPackage is the good macro to pass options
  % tikz loads xcolor, and if you want some extra colors, you need to use xcolor with 
  % dvipsnames,svgnames ( see xcolor.pdf ). But you need to make before loading tikz.
  % I recommend to use utf8 but you can prefer latin1. You can adapt this line.
  % personally  I don't use this line because I work with fourier font and fourier.sty 
  % loads  automatically [T1]{fontenc}. 

% colors


  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3.2cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=fHlavicky] (0,0) rectangle
              rounded corners=20pt,inner sep=11pt,

  {\gdef\sectionlabel{\thesection\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
              rounded corners=7pt,inner sep=3pt,

  {\gdef\subsectionlabel{\thesubsection\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
              rounded corners=5pt,inner sep=2pt,

  {\gdef\subsubsectionlabel{\thesubsubsection\ }}{0pt}


Now you use the class :

share|improve this answer
Wow thank you very much. I had to do some modifications cuz of lots of errors for my example document. But this helped me a lot. But i have few questions because i want to also understand some things for future: Q1: What advantage gives me " \PassOptionsToPackage{dvipsnames,svgnames}{xcolor}" ? Q2:Can you give me some short cooments for the first 5 lines in myreport.cls. ONE MORE TIME :) THANK YOU VERY MUCH – Longobard Mar 30 '12 at 9:32
Yes I will add some comments – Alain Matthes Mar 31 '12 at 6:04

Easiest solution:

  1. Make a class file myreport.cls consisting of your code.
  2. Add \LoadClass{report} at the beginning.
  3. Look at clsguide.pdf for further administrative stuff like \ProvidesClass you should add.
  4. Use with \documentclass{myreport}.
share|improve this answer
Thank you Stephan :) – Longobard Mar 30 '12 at 9:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.