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 was trying to personalize the chapter and section headings using titlesec for my master thesis using the following code

\documentclass{book}
\usepackage{tikz}
\usepackage{titlesec}
\usepackage{lipsum}

\makeatletter
\titleformat{\chapter}[display]
{}% format
{\raggedleft \@chapapp{} \thechapter}% label
{1ex}           % sep
{\raggedleft \Huge \scshape \bfseries}  % before
[\normalfont {\tikz \shade[left color=blue!20,right color=blue, shading angle=45] (0,0) rectangle (\textwidth,5pt);}]% after
\makeatother

\begin{document}
\chapter{Introduction}
\lipsum[1]
\end{document}

Which gives the following output

result

What I want is simply to remove the space between the chapter name and the TikZ drawing and define the vertical space between the drawing and the text (the only one I can get to work is between the chapter and the chapter name). Also which is best for this, titlesec or define all of this as a class file?

I've also tried the second option with similar problems:

\documentclass{book}
\makeatletter
\usepackage{tikz}
\usepackage{palatino}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\def\@makechapterhead#1{%
\vspace*{10\p@}%
{\parindent \z@ \raggedleft \reset@font%
\@chapapp{} \thechapter\par\nobreak%
{\Huge \scshape \bfseries #1\par\nobreak%
\vspace{5pt}
{\tikz \shade[left color=blue!20,right color=blue, shading angle=45] (0,0) rectangle (\textwidth,5pt);}}\par\nobreak%
\vspace{40pt}
}}%
\begin{document}
\chapter{Introduction}
\chapter{Internal Structure}
\section{Internal Strut}
%\section{part 1}
\end{document}
share|improve this question
    
The vertical space is I think just the line height of \Huge. Maybe not the most elegant solution, but you can simply add negative \vspaces: [\vspace{-0.8em}\normalfont {\tikz \shade[left color=blue!20,right color=blue, shading angle=45] (0,0) rectangle (\textwidth,5pt);}\vspace{-1.5em}] –  Caramdir Jun 26 '12 at 15:40

1 Answer 1

up vote 13 down vote accepted

Insert the line directly in the vertical list:

\makeatletter
\def\@makechapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \raggedleft \reset@font
   \@chapapp{} \thechapter\par\nobreak
   {\Huge \scshape \bfseries #1\vadjust{\putline}\par\nobreak}%
   \vspace{40pt}
  }}
\makeatother
\newcommand{\putline}{%
  \kern10pt %%% <-- adjust here
  \hbox{\tikz \shade[left color=blue!20,right color=blue, shading angle=45] (0,0) rectangle (\textwidth,5pt);}%
}

Adjust the amount of kerning as you like.

enter image description here

share|improve this answer
    
Thank you very much, works perfectly and I learned something new: kern :D –  D.Silva Jun 26 '12 at 22:07

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.