Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following block of code doesn't seem to do anything when I define it in a custom class. But when I use the class but put this block in my preamble, it works as expected.

\titleformat{\chapter}
  {\normalfont\sffamily\Huge\scshape}
  {}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=cyan] (0,-1) rectangle
          (\paperwidth,3cm);
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.01\paperheight,rectangle]
              {\color{white}\LARGE CHAPTER \Huge\thechapter};
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.065\paperheight,rectangle]
              {\color{cyan}\Huge\MakeUppercase{#1}};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }

Here's my class file:

\LoadClass[10pt,letterpaper,oneside]{book}
\let\cleardoublepage\clearpage

\RequirePackage[left=2.25in,right=0.75in,top=1.5in,bottom=1.5in]{geometry}
\RequirePackage{graphicx}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage{amsthm, amsfonts, amsmath}
\RequirePackage{thmtools}
\RequirePackage{paralist}
\RequirePackage{tikz}
\RequirePackage[explicit]{titlesec}
\RequirePackage{blindtext, xcolor}
\RequirePackage[T1]{fontenc}
\RequirePackage{mdframed}
\RequirePackage{DejaVuSansCondensed}
\RequirePackage[normalem]{ulem}

\titleformat{\chapter}
  {\normalfont\sffamily\Huge\scshape}
  {}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=cyan] (0,-1) rectangle
          (\paperwidth,3cm);
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.01\paperheight,rectangle]
              {\color{white}\LARGE CHAPTER \Huge\thechapter};
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.065\paperheight,rectangle]
              {\color{cyan}\Huge\MakeUppercase{#1}};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{50pt}{0pt}{}

\titleformat{\section}{\color{cyan}\itshape\LARGE}{\llap{\thesection} #1}{1em}{}
\titleformat{\subsection}{\color{cyan}\normalfont\Large}{\; #1}{1em}{}

\renewcommand*\familydefault{\sfdefault}

% Custom Theorem - Example
\declaretheoremstyle[%
  within=section,%
  spaceabove=5mm,%
  spacebelow=0mm%,
  headfont=\bfseries,%
  headpunct={},%
  postheadspace=\newline,%
  notefont=\normalfont\itshape,%
  notebraces={--~}{},% punctuation before and after the note
]{examplestyle}
\declaretheorem[style=examplestyle,name=Example]{myex}

% Alter spacing after chapter title
\titleformat{\chapter}[display]
    {\normalfont\huge\bfseries}{\chaptertitlename~\thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
\titlespacing*{name=\chapter,numberless}{0pt}{50pt}{40pt}

\declaretheoremstyle[
    within=section,
    spaceabove=10mm,
    spacebelow=3mm,
    headfont=\color{cyan}\normalfont,
    notefont=\normalfont,
    bodyfont=\itshape,
    headpunct=\newline\newline,
    %postheadspace={10pt},
    notebraces={}{},
    headformat={%
        \makebox[-15pt][r]{\normalfont\large\NAME\ \NUMBER\;\;\;\;}\setbox0\hbox{\ }\hspace{-\the\wd0}\large\NOTE%
    },
]{theorem}
\declaretheorem[style=theorem]{theorem}
\declaretheorem[style=theorem]{definition}
\declaretheorem[style=theorem]{example}

\declaretheoremstyle[
    within=section,
    spaceabove=10mm,
    spacebelow=3mm,
    headfont=\color{cyan}\normalfont,
    notefont=\normalfont,
    bodyfont=\itshape,
    headpunct=\newline\newline,
    %postheadspace={10pt},
    notebraces={}{},
    headformat={%
        \makebox[-10pt][r]{}\setbox0\hbox{\ }\hspace{-\the\wd0}\large\NAME%
    },
]{proof}
\let\proof\relax
\declaretheorem[style=proof,qed=\qedsymbol,name=Proof]{proof}
\declaretheorem[style=proof,qed=\qedsymbol,name=Solution]{solution}
share|improve this question
1  
Try putting the definition inside \AtBeginDocument{...}. –  Werner Jan 30 '13 at 4:40
    
The code compiles fine on my machine. Could you provide a picture of the problem so it's easier to see what's missing? –  Nathanael Farley Jan 30 '13 at 7:39
add comment

1 Answer

up vote 4 down vote accepted

You've defined titleformat for chapter twice. When you give a titleformat command, it overwrites any previous formatting in favour of the new one. (Specifically, I'm looking at line 55).

Line 18

\titleformat{\chapter}
  {\normalfont\sffamily\Huge\scshape}
  {}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=cyan] (0,-1) rectangle
          (\paperwidth,3cm);
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.01\paperheight,rectangle]
              {\color{white}\LARGE CHAPTER \Huge\thechapter};
        \node[anchor=west,xshift=.21\paperwidth,yshift=-.065\paperheight,rectangle]
              {\color{cyan}\Huge\MakeUppercase{#1}};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{50pt}{0pt}{}

then, at line 55

\titleformat{\chapter}[display]
   {\normalfont\huge\bfseries}{\chaptertitlename~\thechapter}{20pt}{\Huge}
\titlespacing*{\chapter}{0pt}{50pt}{40pt}
\titlespacing*{name=\chapter,numberless}{0pt}{50pt}{40pt}
share|improve this answer
    
Indeed that was it - thank you very much. I had forgotten about my previous definition. –  agent154 Jan 30 '13 at 21:48
add comment

Your Answer

 
discard

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.