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.

I would like to add some part of code related with ornaments in chapter name to my fancy header definision file.

% Datei fancyheaders.tex
\usepackage{fancyhdr}   % Paket laden
\pagestyle{fancy}   % bereitgestelltes Layout 'fancy' laden

 \renewcommand{\chaptermark}[1]{\markboth{#1}{}}

  \makeatletter
  \def\@makechapterhead#1{%
   \vspace*{50\p@}%
   {\parindent \z@ \raggedright \normalfont
   %\ifnum \c@secnumdepth >\m@ne
    %    \huge\bfseries \@chapapp\space \thechapter
    %    \par\nobreak
    %    \vskip 20\p@
    %\fi
     \interlinepenalty\@M
      \Huge \bfseries #1\par\nobreak
     \vskip 40\p@
        }}
   \makeatother





\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{blindtext}

\newcommand{\chapnumfont}{%     % define font for chapter number
\usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
\fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
\selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!100}  % color for chapter number

\titleformat{\chapter}[display]
{\filleft\bfseries}
{\filleft\chapnumfont\textcolor{chapnumcol}{\thechapter}}
{-24pt}
{\Huge}


\fancyhead{}
%\fancyhead[L]{\leftmark}
\fancyhead[L]{}
\fancyhead[R]{}%{\rightmark}
\fancyfoot{}
\fancyfoot[L]{}
\fancyfoot[C]{}%{\leftmark}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}



% Style "plain" berschreiben, das bei 
%\chapter{...} mit aktiviert wird
\fancypagestyle{plain}{
\lhead{}
\chead{}
\rhead{}
\lfoot{}
\cfoot{}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.0pt}
\renewcommand{\footrulewidth}{0.4pt}}

And add this (when put in to chapter file it destroying fancy hdr setting). Woudl like to add this code to upper definition.

\titleformat{\chapter}[display]
{\normalfont\huge\bfseries\raggedleft}
{\begin{tikzpicture}
\node[text width=3cm,align=center] (chapnum)
 {\fontsize{100}{130}\color{gray}\selectfont\thechapter};%
\node[shift={(-1cm,10pt)},anchor=north west](CNW)
  at (chapnum.north west) {\pgfornament[width=1cm]{7}};
\node[shift={(1cm,10pt)},anchor=north east](CNE)
  at (chapnum.north east) {\pgfornament[width=1cm,symmetry=v]{7}};
\end{tikzpicture}
}
{0pt}
{\Huge}

Thanks for your help.

share|improve this question

1 Answer 1

up vote 8 down vote accepted

Perhaps this is what you are trying to achieve?

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{pgfornament}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\chapnumfont}{%     % define font for chapter number
\usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
\fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
\selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!100}  % color for chapter number

\titleformat{\chapter}[display]
  {\normalfont\bfseries\filleft}
  {\begin{tikzpicture}
    \node[text width=3cm,align=center,inner sep=0pt] (chapnum)
       {\chapnumfont\color{chapnumcol}\thechapter};%
    \node[shift={(-1cm,0pt)},anchor=north west,inner sep=0pt](CNW)
      at (chapnum.north west) {\pgfornament[width=1cm]{7}};
    \node[shift={(1cm,0pt)},anchor=north east,inner sep=0pt](CNE)
      at (chapnum.north east) {\pgfornament[width=1cm,symmetry=v]{7}};
    \end{tikzpicture}%
  }
  {0pt}
  {\Huge}

\begin{document}

\setcounter{chapter}{1}% just for the example
\chapter{Title for a long test chapter}

\end{document}

enter image description here

I suppressed from the original code the parts that were not relevant to the issue with the ornaments; for example, those associated to the fancyhdr package. Don't forget to include them in your actual document.

In a comment it has been requested to produce a similar design for the Table of Contents; this can be done using \titleformat with the numberless key. Below I show one possibility (noe titlesec is loaded with the explicit option):

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{pgfornament}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\chapnumfont}{%     % define font for chapter number
\usefont{T1}{pnc}{b}{n}%      % choose New Chancery, bold, normal shape
\fontsize{100}{100}%          % font size 100pt, baselineskip 100pt
\selectfont%                  % activate font
}
\colorlet{chapnumcol}{gray!100}  % color for chapter number

\newcommand\MyOrnament[1]{%
  \makebox[3.8em][#1]{%
    \raisebox{.5\height}{\pgfornament[width=1cm]{7}}}%
}

\titleformat{\chapter}[display]
  {\normalfont\bfseries\filleft}
  {\begin{tikzpicture}
    \node[text width=3cm,align=center,inner sep=0pt] (chapnum)
       {\chapnumfont\color{chapnumcol}\thechapter};%
    \node[shift={(-1cm,0pt)},anchor=north west,inner sep=0pt](CNW)
      at (chapnum.north west) {\pgfornament[width=1cm]{7}};
    \node[shift={(1cm,0pt)},anchor=north east,inner sep=0pt](CNE)
      at (chapnum.north east) {\pgfornament[width=1cm,symmetry=v]{7}};
    \end{tikzpicture}%
  }
  {0pt}
  {\Huge#1}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\bfseries\filleft}
  { }
  {0pt}
  {\MyOrnament{l}{\Huge#1}\MyOrnament{r}}

\begin{document}


\tableofcontents
\listoffigures
\setcounter{chapter}{1}% just for the example
\chapter{Title for a long test chapter}

\end{document}

An image of the resulting ToC:

enter image description here

share|improve this answer
    
Thaks, that work perfect. –  user35815 Feb 11 at 23:45
    
How complex can be adding ornament to the table of contents? {\tableofcontents \newpage \begingroup \let\cleardoublepage\relax \addcontentsline{toc}{chapter}{LoF} \listoffigures} –  user35815 Feb 11 at 23:49
    
@user35815 where should the ornaments appear for the table of contents? –  Gonzalo Medina Feb 11 at 23:50
    
Think, the same patern as in chapter but a bit smaller –  user35815 Feb 11 at 23:52
    
@user35815 it's not difficult, but in what position should the ornaments go? The table of contents has no number to surround with the ornaments. –  Gonzalo Medina Feb 11 at 23:58

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.