I'm using Latex to write my thesis in Hungarian, so I include in the preamble the following:
\usepackage[magyar]{babel}
Once this is loaded, I get "Chapter", "Figure", etc. in Hungarian and with matching typography.
I would like to use a sans-serif font in chapter, section and subsection headings. To achieve this, I use the sectsty
package, set up like this:
\usepackage{sectsty}
\chapterfont{\usefont{T1}{qhv}{b}{n}\selectfont\huge}
\sectionfont{\usefont{T1}{qhv}{b}{n}\selectfont\LARGE}
\subsectionfont{\usefont{T1}{qhv}{b}{n}\selectfont\Large}
LaTeX correctly sets sections and subsections in TeX Gyre
, but chapter headings stay unchanged, while unnumbered chapters (\chapter*{...}
)
get changed like they are supposed to.
Example:
while
I suspect the conflict is caused by babel
, which redefines the chapter heading in some way sectsty
won't be able to handle.
Does anyone have any idea how to manage this? I have tried titlesec, but it behaves in the same way.
Thank you!
Edit:
I created a short document with every relevant package to recreate the problem:
\documentclass[a4paper]{report}
\usepackage[magyar]{babel}
\usepackage[utf8]{inputenc}
\usepackage{t1enc}
\usepackage{blindtext}
\usepackage{sectsty}
\chapterfont{\usefont{T1}{qhv}{b}{n}\selectfont\huge}
\sectionfont{\usefont{T1}{qhv}{b}{n}\selectfont\LARGE}
\subsectionfont{\usefont{T1}{qhv}{b}{n}\selectfont\Large}
\begin{document}
\chapter{Example chapter} %% this one is not working correctly
\blindtext
\section{Example section}
\blindtext
\subsection{Example subsection}
\blindtext
\chapter*{Example unnumbered chapter}
\blindtext
\end{document}
If I comment out babel
, sectsty
works as expected but I lose the localization obviously.
Best Answer
The
magyar
option seizes the initiative and changes the code for\@chapter
to reflect the original code in the class and ignores the settings bysectsty
. It does nothing to\@schapter
, which is the reason you see sans serif in unnumbered chapters.Use
titlesec
, instead: