[Tex/LaTex] Problems with fancy style and KOMA-Script

fancyhdrkoma-script

I would like to write an article with "Koma-Script" and use the "fancy page style". Therefore, I use the following commands before beginning the document:

\documentclass[paper=a4, spanish, fontsize=12pt]{scrartcl} 

\usepackage[utf8]{inputenc}

\usepackage[spanish]{babel}

\usepackage{listings}

\usepackage{color}

\usepackage{url}

\usepackage{fourier} % Use the Adobe Utopia font for the document - comment 
this line to return to the LaTeX default

\usepackage{amsmath,amsfonts,amsthm} % Math packages

\usepackage{paralist}

\usepackage{eurosym}

\usepackage{graphicx}

\usepackage{caption}

\usepackage{titling}

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template

\usepackage{sectsty} % Allows customizing section commands

\usepackage{fancyhdr} % Custom headers and footers

\usepackage{fancylabel}

\usepackage{float}

\usepackage{caption} 

\usepackage{subfigure} 

\usepackage{flushend}

\usepackage{mathtext}

\usepackage{epsfig}

\pagestyle{fancy}

\fancyhf{}

\fancyhead[RO]{\textbf{\thepage}}

\fancyhead[LO]{\textbf{\rightmark}}

When I compile the programm it makes the PDF, but the sections and the table of contents are not highlighted in bold. Moreover, the programm produce the following error:

Usage of package `fancyhdr' together(scrartcl) with a KOMA-Script class is not > recommended.

incompatible usage of \@ssect detected.

incompatible usage of \@ssect detected.

incompatible usage of \@ssect detected.

P.S.The programm I use in order to write and compile in LaTeX is: "TeXstudio"

I have looked for the whole warning message and i found it:

Class scrartcl Warning: incompatible usage of \@ssect detected.

(scrartcl) You've used the KOMA-Script implementation of \@ssect

(scrartcl) from within a non compatible caller, that does not

(scrartcl) \scr@s@ct@@nn@m@ locally.

(scrartcl) This could result in several error messages on input line 85.

This line is where I wrote the \tableofcontents, and in the Pdf it is not in bold as it has to be.

Best Answer

If you use package fancyhdr with a KOMA-Script class you will get the warning:

Class scrartcl Warning: Usage of package fancyhdr together with a KOMA-Script class is not recommended. I'd suggest to use package scrlayer or scrlayer-scrpage, because they support KOMA-Script classes. With fancyhdr several features of class scrartcl like options headsepline, footsepline or command\MakeMarkcase and the commands \setkomafont and\addtokomafont for the page style elements need explicite user intervention to work.

Note that this is only a warning and not an error message. So if you understand that some KOMA-Script features and commands for page header and footer will not work with this package, you can load it and define your page headers and footers with it.

But package fancyhdr does not effect the font of the section headings inside the text body.

Loading the package sectstyle with a KOMA-Script class results in warnings

Class scrartcl Warning: incompatible usage of \@ssect detected. You've used the KOMA-Script implementation of \@ssectfrom within a non compatible caller, that does not \scr@s@ct@@nn@m@ locally.

at least for \tableofcontents, \listoffigures and \listoftables. Note that KOMA-Script has its own commands for changing the font settings or the alignment of section titles. So do not use package sectsty or titlesec.

But loading the package sectsty does still not unbold the section titles as you can see in the following example (unrelated packages are removed):

\documentclass{scrartcl} 
\usepackage{sectsty}% <- only for the example - do not use this package with a KOMA-Script class!!
\usepackage{fancyhdr}% <- replacing by scrlayer-scrpage suggested
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\textbf{\thepage}}
\fancyhead[LO]{\textbf{\rightmark}}

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\section{A section}
Text
\end{document}

Result:

enter image description here

So I guess: there must be either one of the sectsty commands \allsectionfonts or \sectionfont or one of the KOMA-Script commands \setkomafont or \addkomafont changing the settings for one of the font elements disposition or section in your document. All of them can unbold the section titles, but unfortunaly there was no MWE in your question showing your settings.

Related Question