# Same vertical spacing for chapter and chapter*

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}

\titleformat{\chapter}[display]
{\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?

-
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

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}

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

\begin{document}

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

\end{document}


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}

\titleformat{\chapter}[display]
{\filleft\Large\textsc{\chaptertitlename}\rlap{~\Huge\thechapter}}
{1ex}
{\titlerule\vskip1ex\filleft}
\titleformat{name=\chapter,numberless}[display]
{\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}


-
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