2

I want to make the chapter number and title to be in the same line as this question. However, when I want to apply the answer, it does not work with the package babel with the option 'magyar'.

\documentclass[a4paper,12pt]{report}

% \usepackage[magyar]{babel} % Does not work \usepackage[english]{babel} % Works

\usepackage{titlesec} \titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}

\usepackage{lipsum}

\begin{document} \chapter{Introduction} \lipsum[1] \end{document}

output with 'magyar' and with 'english'

Does anybody have an idea how to use \titleformat and babel together?

EDIT

According to @esdd answer the key is to use

\def\magyarOptions{chapterhead=unchanged}

before

\usepackage[magyar]{babel}

In this case, I had to reformat chapter title manually (to be 'magyar'):

\titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\arabic{chapter}. Fejezet:}{1ex}{}
Tom Solid
  • 839

1 Answers1

3

You have to use \def\magyarOptions{chapterhead=unchanged} before loading package babel with option magyar.

\def\magyarOptions{chapterhead=unchanged}
\usepackage[magyar]{babel}

Example:

\documentclass[a4paper,12pt]{report}
\usepackage[T1]{fontenc}

\def\magyarOptions{chapterhead=unchanged} \usepackage[magyar]{babel}

\usepackage{titlesec} \titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter:}{1em}{}

\renewcommand*{\chaptertitlename}{\expandafter\MakeUppercase\chaptername} \usepackage{xpatch} \xapptocmd{\appendix} {\gdef\chaptertitlename{\expandafter\MakeUppercase\appendixname}} {}{\undefined}

\usepackage{lipsum}

\begin{document} \tableofcontents \chapter{Introduction} \lipsum[1] \appendix \chapter{Appendix chapter} \end{document}

enter image description here

esdd
  • 85,675