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 cannot find a way to change chapter style with babel included (for hungarian language). Here is the example:

\documentclass[a4paper]{report}
\usepackage[magyar]{babel}
\usepackage{titlesec}

\titleformat{\chapter}[hang]
{\normalfont}
{\LARGE\thechapter.}
{10pt}
{\LARGE\MakeUppercase}
[\normalfont]
\titlespacing{\chapter}{0pt}{0pt}{30pt}[0pt]

\begin{document}
\chapter{First chapter}
\end{document}

If I comment out the \usepackage[magyar]{babel} line, everything works as expected, however, with babel it does not work. Is it possible to style chapters (and sections, etc.) while using babel?

share|improve this question
    
Sorry, but I don't get any error. What TeX distribution are you using? –  egreg May 23 '13 at 19:53
    
I don't get an error either. (MiKTeX 2.9 last time updated 2 weeks ago) –  Dominic Michaelis May 23 '13 at 19:55
    
I'm using MikTeX 2.9, but I do not get any error, but chapter does not look like I specified with \titleformat, but looks like babel's default. With english babel \usepackage[english]{babel} it works properly. –  Gergely May 23 '13 at 20:04
4  
The magyar module for babel does a lot of stuff \AtBeginDocument and this might be the cause. One possible workaround is to move the \titleformat and \titlespacing commands after \begin{document}. –  Gonzalo Medina May 23 '13 at 20:20
1  
The Hungarian support module for Babel restores the meaning of \chapter after \begin{document}, while not giving any method for overriding this choice. –  egreg May 23 '13 at 22:55
show 1 more comment

1 Answer

The magyar module for babel does a lot of stuff \AtBeginDocument; amongst other things (as egreg noticed in his comment), it restores the meaning of \chapter after \begin{document}, while not giving any method for overriding this choice. One possible workaround is to move the \titleformat and \titlespacing commands after \begin{document}:

\documentclass[a4paper]{report}
\usepackage[magyar]{babel}
\usepackage{titlesec}

\begin{document}

\titleformat{\chapter}[hang]
{\normalfont}
{\LARGE\thechapter.}
{10pt}
{\LARGE\MakeUppercase}
[\normalfont]
\titlespacing{\chapter}{0pt}{0pt}{30pt}[0pt]
\chapter{First chapter}

\end{document}

enter image description here

share|improve this answer
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.