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 wanted to style the chapter name. I referred the following link : how-to-create-specific-chapter-style-in-book-documentclass

Here is my code:

%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{titlesec}
% Can also use centering, or hcentering

\titleformat{\chapter}[display]
  {\bfseries\Large}
  {\filright\MakeUppercase{\chaptertitlename}\Huge\thechapter}
  {1ex}
  {\titlerule\vspace{1ex}\filleft}
  [\vspace{1ex}\titlerule]

\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
BackTrack is a distribution designed by Jason Dennis based on the Ubuntu Linux distribution aimed at digital forensics and penetration testing use. BackTrack provides users with easy access to a comprehensive and large collection of security-related tools ranging from port scanners to Security Audit. Support for Live CD and Live USB functionality allows users to boot BackTrack directly from portable media without requiring installation, though permanent installation to hard disk and network is also an option.\par
\end{document} 

I get the following output: enter image description here

After using the explicit option in titlesec and numbering the chapter as per the solution given, I get this output:

enter image description here

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You're loading the titlesec package twice- only the first instance actually counts, the second one is ignored.

When you use the explicit option for the titlesec package, you have to specify the heading title using #1.

As such, you could use, for example,

\titleformat{\chapter}[display]
  {\bfseries\Large}
  {\filright\MakeUppercase{\chaptertitlename}\Huge\thechapter}
  {1ex}
  {\titlerule\vspace{1ex}\filleft #1}
  [\vspace{1ex}\titlerule]

or else remove the explicit option and simply load the titlesec package using

\usepackage{titlesec}

in which case, you can stick with your original code.

share|improve this answer
    
How do I align the chapter title?filleft or filcenter doesn't seem to work?I want to center align the title –  subham soni Feb 1 at 4:42
    
When I use explicit option and add ~#1 to the code as mentioned , I get illegeal parameter error??? @cmhughes –  subham soni Feb 1 at 4:58
    
I have edited my question .. –  subham soni Feb 1 at 5:05
    
@subhamsoni I see that you have edited your question- however, it still does not contain your desired output. It looks like Harish Kumar edited my answer as he was able to predict what you wanted. In the future, please make sure your question contains enough details :) –  cmhughes Feb 1 at 16:10
    
Sure @cmhughes... –  subham soni Feb 1 at 16:13

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.