4

I wanted to style chapter headings, found out about titlesec and wrote the document like this:

\documentclass[a4paper,12pt]{book}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[serbianc]{babel}

\usepackage{titlesec}
\usepackage{xcolor}

\definecolor{crvena}{rgb}{.647,.129,.149}
\definecolor{plava}{rgb}{.204,.353,.541}

\titleformat
{\chapter} % command
[display] % shape
{\bfseries\flushright\Huge\color{crvena}} % format
{\ \thechapter} % label
{0.5ex} % sep
{
\vspace{1ex}
} % before-code
[
\vspace{-0.5ex}%
\color{plava}\rule{\textwidth}{2.3pt}
] % after-code

\begin{document}
\tableofcontents
\chapter{Лавиринт}

After that I wrote some text and finished with:

\end{document}

The result is fine, as can be seen from the image:

enter image description here

But the problem is now that there are errors in table of contents:

ToC:

enter image description here

What has caused 1 [Pleaseinsertintopreamble] to be written instead of 1 Лавиринт and how to fix it?

EDIT 1: I tried to use fancyhdr, but got this:

ToC is fine: enter image description here

but header is not:

enter image description here

2
  • Welcome to TeX.SX! The problem usually is associated to the utf8x option to inputenc rather than utf8.
    – egreg
    Commented Mar 8, 2014 at 20:09
  • Thanks. :) I've seen that the problem occurs with utf8x, so I was somewhat surprised to see it happen with utf8 as well. If I add \usepackage{fancyhdr}, ToC works fine, but then headers are wrong. I'm new to both fancyhdr and titlesec, so I have no clue what's going on. : )
    – Milos
    Commented Mar 8, 2014 at 20:17

1 Answer 1

4

The serbianc module for babel seems to enforce using the utf8x option for inputenc and the package ucs which is, in my opinion, wrong.

A workaround seems to be specifying utf8x prior to utf8.

\documentclass[a4paper,12pt]{book}
\usepackage[T2A]{fontenc}
\usepackage[utf8x,utf8]{inputenc}

\usepackage[serbianc]{babel}

However, I would ask the maintainer of babel to remove the setting, leaving the user the choice of what option for inputenc to use. And I'd much prefer utf8.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .