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 am trying to make my own style for chapter headings using koma-script and titlesec. The document compiles fine, but some errors are generated:

Package titlesec Error: Entered in horizontal mode \chapter{Um capítulo de teste}
Missing number, treated as zero \chapter{Um capítulo de teste}
Illegal unit of measure (pt inserted) \chapter{Um capítulo de teste}

A MWE follows below:

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{brazil}
\usepackage{fontspec}
\usepackage[dvipsnames]{xcolor}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{titlesec}


\titleformat{\chapter}[display]
{\titlerule[.8pt] \vspace{10pt} \bfseries \huge %
{\filleft \hrulefill \chaptertitlename % 
\marginpar{\mbox{\fontsize{60}{72}\selectfont\color{gray}\thechapter} } } } %
{}{\titlerule[5pt] %
\vspace{2pc}%
}{}

\begin{document}
\chapter{Um capítulo de teste}

\end{document}
share|improve this question

1 Answer 1

up vote 2 down vote accepted

You're using wrongly \titleformat:

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{brazil}
\usepackage{fontspec}
\usepackage[dvipsnames]{xcolor}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{titlesec}


\titleformat{\chapter}[display]
  {\titlerule[.8pt]\vspace{10pt}\bfseries\huge}% before code
  {\filleft \hrulefill\ \chaptertitlename %
   \smash{\makebox[0pt][l]{\hspace{1cm}\fontsize{60}{72}\selectfont\color{gray}\thechapter}}}% label format
  {1ex}% space before the title part
  {\titlerule[5pt]\vspace{2pc}}% format before the title
  {}% the title

\begin{document}
\chapter{Um capítulo de teste}

\end{document}

Don't use \marginpar, but rather a "smashed" box that so takes zero space, as in the shown code.

enter image description here

share|improve this answer
    
Great, it worked fine. I didn't know the \smash command, it's easier than using \marginpar in this case. –  Joseph Jul 3 '13 at 16:09

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.