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 use \chapter*{} in the \frontmatter and \chapter{} in the \mainmatter.

I use titlesec and the styling of the chapter headings is this:

\documentclass[10pt,a4paper,openany,oneside]{book}
...
\usepackage{titlesec}
\newcommand*{\justifyheading}{\raggedleft}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\justifyheading}
  {\filleft\Large\textsc{\chaptertitlename}~\Huge\thechapter}
  {1ex}
  {\titlerule\vspace{0ex}\filleft}

Question: How do I get the chapter title to be at the same level? See the problem in this screenshot, I want the titlerules to be at the same level (i.e. same distance from the top).

Bonus-question: How do I push the "Chapter 1" to the right so the number is hanging outside the margin?

share|improve this question
    
Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Marco Daniel May 11 '13 at 17:46
    
Thanks, I will do in the future! –  swenedo May 12 '13 at 0:06
add comment

1 Answer

up vote 4 down vote accepted

One possibility is to have two definitions: one for numbered chapters and the other one, for unnumbered chapters, using the numberless key. In the definition for unnumbered chapters, some \phantoms are used to hide the chapter name and the chapter number; for the bonus question, a \rlap will do the job:

\documentclass{book}
\usepackage[a5paper]{geometry}% just for the example
\usepackage{titlesec}

\newcommand*{\justifyheading}{\raggedleft}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\justifyheading}
  {\filleft\Large\textsc{\chaptertitlename}\rlap{~\Huge\thechapter}}
  {1ex}
  {\titlerule\filleft}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\bfseries\justifyheading}
  {\filleft\Large\textsc{\phantom{\chaptertitlename}}\rlap{~\Huge\phantom{\thechapter}}}
  {1ex}
  {\titlerule\filleft}

\begin{document}

\chapter{Test Numbered Chapter}
\chapter*{Test Unnumbered Chapter}

\end{document}

enter image description here

With your current settings, you need to use a font allowing you bold-faced small caps, although I would suggest you to have only small caps (not boldfaced).

As barbara beeton has suggested, your current settings will result in the title being too close to the rule; adding some spacing would produce a better result:

\documentclass{book}
\usepackage[a5paper]{geometry}% just for the example
\usepackage{titlesec}

\newcommand*{\justifyheading}{\raggedleft}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\justifyheading}
  {\filleft\Large\textsc{\chaptertitlename}\rlap{~\Huge\thechapter}}
  {1ex}
  {\titlerule\vskip1ex\filleft}
\titleformat{name=\chapter,numberless}[display]
  {\normalfont\huge\bfseries\justifyheading}
  {\filleft\Large\textsc{\phantom{\chaptertitlename}}\rlap{~\Huge\phantom{\thechapter}}}
  {1ex}
  {\titlerule\vskip1ex\filleft}

\begin{document}

\chapter{Test Numbered Chapter}
\chapter*{Test Unnumbered Chapter}

\end{document}

enter image description here

share|improve this answer
    
a bit of separation between the rule and the title would look nicer. –  barbara beeton May 11 '13 at 20:20
    
@barbarabeeton True, but these are the OP's original settings. I will suggest increasing the separation in my answer. –  Gonzalo Medina May 11 '13 at 20:33
    
aha! i didn't look carefully at his code; i looked instead at the linked screenshot. –  barbara beeton May 11 '13 at 20:35
    
@barbarabeeton I added the code to produce some spacing between the rule and the title. –  Gonzalo Medina May 11 '13 at 21:00
    
Thanks a lot! I agree with @barbarabeeton, it looks nicer with a bit of separation :) I don't know why I had \vspace{0ex} in the posted code. –  swenedo May 12 '13 at 0:10
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.