# My custom style doesn't work

It is my first experience with LaTeX. This may be some sort of dummy question. But anyway. I've spend a day with TeXLive on Fedora. And here is the problem. I have some file 1:

\documentclass{book}
\usepackage{vit} % it's my own vit.sty file
\usepackage[utf8]{inputenc}

\usepackage{vmargin}
\setpapersize{A4}
\setmarginsrb{2cm}{1.5cm}{1cm}{1.5cm}{0pt}{0mm}{0pt}{13mm}
\usepackage{indentfirst}
\sloppy

\begin{document}

\chapter{AutoSDK}

blabla

\end{document}


and a second file which is my "own" style vit.sty:

\NeedsTeXFormat{LaTeX2e}
\RequirePackage{color}
\definecolor{vit_black100}{cmyk}{0.0, 0.0, 0.0, 1}
\definecolor{vit_gray90}{cmyk}{0.0, 0.0, 0.0, 0.90} %can be used as background color
\definecolor{vit_gray70}{cmyk}{0.0, 0.0, 0.0, 0.70} %can be used as background color
\definecolor{vit_gray5}{cmyk}{0.0, 0.0, 0.0, 0.05} %can be used as background color
\definecolor{vit_snow}{cmyk}{0.0, 0.0, 0.0, 0.0} %can be used as background color
\definecolor{vit_whitecolor}{cmyk}{0.25, 0.0, 0.0, 0.10}
\definecolor{vit_yolkcolor}{cmyk}{0.0, 0.10, 1, 0}

\titleformat{\chapter}
{\textsc{\MakeTextLowercase{\thesection}}}%
{1em}
{\spacedlowsmallcaps}
[{\color{vit_whitecolor}\titlerule[2.5pt]} 123]


and LaTeX returns the following error:

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012)
restricted \write18 enabled.
entering extended mode
(./AutoSDK.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2012-05-30, ngerman-x-2012-05-30, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, friulan, galician, german, ngerman, swissgerman, monogreek, greek, h
ungarian, icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, ma
rathi, oriya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian,
kurmanji, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk,
polish, portuguese, romanian, romansh, russian, sanskrit, serbian, serbianc, s
lovak, slovenian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian,
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/bk10.clo)) (./vit.sty
(/usr/local/texlive/2012/texmf-dist/tex/latex/titlesec/titlesec.sty)
(/usr/local/texlive/2012/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2012/texmf-dist/tex/latex/latexconfig/color.cfg)
(/usr/local/texlive/2012/texmf-dist/tex/latex/graphics/dvips.def)
(/usr/local/texlive/2012/texmf-dist/tex/latex/graphics/dvipsnam.def)))
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/inputenc.sty
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/utf8.def
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/local/texlive/2012/texmf-dist/tex/latex/base/omsenc.dfu)))
(/usr/local/texlive/2012/texmf-dist/tex/latex/vmargin/vmargin.sty
Package: vmargin 2004/07/15 V2.5 set document margins (VK)
) (/usr/local/texlive/2012/texmf-dist/tex/latex/tools/indentfirst.sty)
(./AutoSDK.aux)
! Undefined control sequence.
\reserved@c ...abelfalse \fi \ifnum \ttll@chapter
>\c@secnumdepth \ttl@label...
l.13 \chapter{
AutoSDK}
?

-
Why do you have the [loadonly] option to titlesec? If you remove that it compiles. – Peter Grill Oct 27 '12 at 19:29
I'd suggest you make your Minimal Working Example more minimal; Try removing some of the other packages you have, until only your package is left. Also remove things such as sloppy: Basically, you want the minimum amount of code possible, so we can tell that the problem is what you think it is, and no somewhere else in the code. – Canageek Oct 27 '12 at 19:31
I suggest you not to use vmargin, but geometry for setting the page parameters; for instance, vmargin is not compatible with pdfpages and other packages. – egreg Oct 28 '12 at 14:28

Remove the loadonly option for titlesec; i.e., instead of

\RequirePackage[loadonly]{titlesec}


use

\RequirePackage{titlesec}


in vit.sty. If you use the loadonly option, you will have to define the sectional unit formatting from scratch, and according to your definition for \titleformat{\chapter} you are not willing to do that.

You also need to make the following modifications to \titleformat{\chapter}:

\RequirePackage{textcase}
\titleformat{\chapter}
{\textsc{\MakeTextLowercase{\thesection}}}%
{1em}
{}
[{\color{vit_whitecolor}\titlerule[2.5pt]}123]

• You were using \textcolor{vit_whiteshadow} but \textcolor requires two arguments, so I changed it to \color{vit_whiteshadow}.

• Since you are using \MakeTextLowercase, you need the textcase package; by the way, do you really need \MakeTextLowecase for \thesection?

• You are using \spacedlowsmallcaps which is not a standard LaTeX command, so you also need to load the package providing this command if you want to use it; however, the only package I know that provides this command is classicthesis and loading this package will totally change your layout which might not be what you want; if you want to use this command on its own, you could copy the definition of \spacedlowsmallcaps from classicthesis.sty.

-
thank you! I seems works. But here is another problem: Package titlesec Error: Entered in horizontal mode. If you'll send me to google I won't be offended :) – dmigous Oct 27 '12 at 20:39
@dmigous I updated my answer with some explanatory comments. – Gonzalo Medina Oct 27 '12 at 21:38