1

When I'm writing a book using KOMA-Script usung class scrbook with package fancyhdr, I get a weird line at the top of the first page:

enter image description here

Here is MWE:

% Preview source code

%% LyX 2.3.2-2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,oneside,english,hebrew,numbers=noenddot]{scrbook}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{fontspec}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parindent}{0bp}
\usepackage{color}
\usepackage[unicode=true,pdfusetitle,
 bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
 breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true]
 {hyperref}
\hypersetup{
 linkcolor=blue}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\hebrewfonttt[Script=Hebrew]{Miriam Mono CLM}
\newfontfamily\hebrewfontsf[Script=Hebrew]{Bellefair}


\fancypagestyle{plain}{ %
  \fancyhf{} 
  \renewcommand{\headrulewidth}{3pt} 
  \renewcommand{\footrulewidth}{0pt}
    \lhead{AAA}
    \cfoot{\thepage}
}

\makeatother

\usepackage{polyglossia}
\setdefaultlanguage{hebrew}
\setotherlanguage{english}
\begin{document}
\bigskip{}

\begin{center}
\fontsize{80}{80}\selectfont{\textbf{אבג}}
\par\end{center}

\bigskip{}


\part{אבג}

\chapter{אאאא}

\section{בבבב}

אאא

בבב

\section{אבג}
\end{document}

No matter how I change the code -- I can't control this line.

Do you know how can I remove it?

  • Comment line 10 \pagestyle{fancy}? – AboAmmar May 23 '19 at 16:44
  • The log says Usage of package fancyhdr' together (scrbook) with a KOMA-Script class is not recommended. (scrbook) I'd suggest to use ….. – user170109 May 23 '19 at 16:58
  • @AboAmmar are you able to follow up comment with answer as that does seem to be at root of the problem – user170109 May 23 '19 at 18:33
3

Well, in your code are some issues:

  1. Because I do not know hebrew and the specific problems with I simply deleted the usage of hebrew and hebrew font in your given code.
  2. The usual way to define a titlepage in scrbook is to use command \maketitle (I added in the following mwe) or to define a titlepage with environment titlepage.
  3. fancyhdr with scrbook can result in problems, better would be to use scrlayer-scrpage.
  4. Your issue results from the using of this total unusual code printing the titlepage:

    \bigskip{}
    
    \begin{center}
    \fontsize{80}{80}\selectfont{\textbf{titel}}
    \par\end{center}
    
    \bigskip{}
    

    That code results that fancyhdr adds an headrule because your then working \pagestyle{fancy} added in your preamble added the headrule you do not want. To get rid of that you have to add

    \thispagestyle{empty} 
    

    after \begin{document} or much better use \maketitle or environment titlepage.

In the following mwe without hebrew fonts I used first your wrong way printing the title and added afterward the correct usage of \maketitle:

\documentclass[%
  a4paper,oneside,english,
% hebrew,
  numbers=noenddot
]{scrbook}

\usepackage{amsmath}
\usepackage{amsthm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\usepackage{color}

\usepackage{blindtext}

\usepackage[%
  unicode=true,pdfusetitle,
  bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
  breaklinks=false,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true
]{hyperref}
\hypersetup{%
  linkcolor=blue
}


\fancypagestyle{plain}{ %
  \fancyhf{} 
  \renewcommand{\headrulewidth}{3pt} 
  \renewcommand{\footrulewidth}{0pt}
    \lhead{AAA}
    \cfoot{\thepage}
}


\begin{document}
\thispagestyle{empty} % <===============================================
\bigskip{}

\begin{center}
\fontsize{80}{80}\selectfont{\textbf{titel}}
\par\end{center}

\bigskip{}


\title{this is the title}
\author{john doe}
\maketitle % <==========================================================


\part{part}

\chapter{chapter}

\section{sectiona}

\blindtext

\section{sectionb}

\blindtext
\end{document}

and its result:

resulting titlepages

| improve this answer | |
  • The only thing that works (at the real example, not at the MWE) is \thispagestyle{empty} - so you solve it for me with this simple code, but maybe for other uses the - I'll use the other part of the solution :-) – heblyx May 26 '19 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.