1

I am very new to LaTex and I am trying to create a document, where every page (well every page after the title page) shows the same header picture on the top left corner. I am using Overleaf.

I tried it with the fancyhdr as shown as here and with titleps as shown here.

So far I've managed to place the header on a few pages. It seems like working on every second page of each chapter. But then the page number disappears...

Does anybody see's what I am doing wrong? .

enter image description here

Source

\documentclass[a4paper, liststotoc]{scrreprt}

%Packages \usepackage[bmargin=4cm,tmargin=2cm,headheight=5cm]{geometry} %Seitenränder definieren \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage[ngerman, english]{babel} \usepackage{glossaries} \usepackage[colorlinks, urlcolor=blue, linkcolor=black, citecolor=black]{hyperref} \usepackage[german, noabbrev, nameinlink]{cleveref} %Automatische Verweise mit \cref{} oder \cpageref{} auf \label{}. Bei englischer Arbeit muss "german" durch "english" ersetzt werden. \usepackage{float} %Unterdrückt das Fliessen eines Bildes wenn statt "h" "H" als float angegeben wird. \usepackage{pdfpages} \usepackage{amstext} \usepackage{lineno} \usepackage{amssymb} \usepackage{graphicx} \usepackage{makeidx} \usepackage{listings} \usepackage[round, comma, sort&compress]{natbib} %Bibliografie \usepackage{fancyhdr} \usepackage{lipsum} %------------------------------------------------------------------------------------------------% %Konfigurationen

%Bibliografie-Stil \bibliographystyle{ieeetr}

%Kopfzeile mit Logo \pagestyle{fancy} \fancyhf{} \fancyhead[L]{\raisebox{-1\height}[0pt][0pt]{\includegraphics{Bilder/FHNWLogo.jpg}}} \renewcommand\headrulewidth{0.0pt} \renewcommand\footrulewidth{0pt} \newcommand{\chpt}[1]{\chapter{#1}\thispagestyle{fancy}}

%Listing-Namen überschreiben \renewcommand\lstlistingname{Quellcode} \renewcommand\lstlistlistingname{Quellcodes}

%Glossar \makeglossaries

%------------------------------------------------------------------------------------------------% \begin{document} \thispagestyle{empty}
\selectlanguage{ngerman} %Wenn Arbeit auf Englisch geschrieben wird auf "english" setzen %Titelseite \input{Kapitel/Titelseite} %Seitennummerierung ab hier \pagenumbering{arabic}\setcounter{page}{2}

\addcontentsline{toc}{chapter}{Abstract}\input{Kapitel/Abstract} \addcontentsline{toc}{chapter}{Ehrlichkeitserklärung}\input{Kapitel/Ehrlichkeitserklärung}

%Inhaltsverzeichnis \setcounter{secnumdepth}{3} \setcounter{tocdepth}{3} \tableofcontents{}

%Kapitel \input{Kapitel/Einleitung} \input{Kapitel/Umsetzung} %Verzeichnisse %Glossar \addcontentsline{toc}{chapter}{Abkürzungsverzeichnis} %Wörter müssen mit \Gls{} markiert werden, damit Einträge erscheint. Definition in Kapitel/Glossar.tex \printglossary[type=main,title={Abkürzungsverzeichnis}] %Literaturverzeichnis \addcontentsline{toc}{chapter}{Literaturverzeichnis}\bibliography{Referenzen/Quellen} %Abbildungsverzeichnis \listoffigures %Tabellenverzeichnis \listoftables %Quellcodes \lstlistoflistings

%Anhang \addcontentsline{toc}{chapter}{Anhang}\input{Kapitel/Anhang}

\end{document}

Source of Umsetzung

\chapter{Umsetzung}
\section{Forschung}
\subsection{REST-API}
Diese Arbeit ist ein Teil eines grösseren Projektes. Das Ziel dieses Projektes ist es Hüftdysplasien von Hunden mittels Bewegungsanalyse zu erkennen und klassifizieren. Die Bewegung wird mit Hilfe von Bewegungssensoren aufgezeichnet. Die Arbeit soll dabei helfen, die bisher gesammelten Daten besser zu verstehen, sowie die Zusammenhänge zwischen den Bewegungsdaten und den Körpereigenschaften der Hunde aufzuzeigen.\pagebreak{}

\subsection{REST-API} Diese Arbeit ist ein Teil eines grösseren Projektes. Das Ziel dieses Projektes ist es Hüftdysplasien von Hunden mittels Bewegungsanalyse zu erkennen und klassifizieren. Die Bewegung wird mit Hilfe von Bewegungssensoren aufgezeichnet. Die Arbeit soll dabei helfen, die bisher gesammelten Daten besser zu verstehen, sowie die Zusammenhänge zwischen den Bewegungsdaten und den Körpereigenschaften der Hunde aufzuzeigen.\pagebreak{}

Remo
  • 169
  • 7
  • Welcome to TeX.SE! – Mensch Nov 14 '21 at 15:27
  • When I replace your image (that I obviously don't have) with example-image I do get the image in the header. Did you check the .log file for errors? – Pieter van Oostrum Nov 14 '21 at 15:57
  • 1
    And, by the way, you will not have a header on the first page of each chapter. So you have to make sure that you have more than one page in at least one chapter to see the header. – Pieter van Oostrum Nov 14 '21 at 16:02
  • aaah this is the issue! I didn't know about that, thank you. Is there any way to place it on every page, regardless the chapter? – Remo Nov 14 '21 at 16:07
  • oh I need only the image, no chapter information etc. on the right side. – Remo Nov 14 '21 at 16:11
  • You could try adding \thispagestyle{fancy} after \chapter. You could use \fancypagestyle{plain} to change the plain pagestyle (default first page of chapter). You could modify \chapter to not use \thispagestyle{plain}. – John Kormylo Nov 15 '21 at 15:18
  • @JohnKormylo this is what I've done already with \newcommand{\chpt}[1]{\chapter{#1}\thispagestyle{fancy}} Makes no difference. – Remo Nov 15 '21 at 19:18

2 Answers2

3

It is suggested to use package scrlayer-scrpage together with a KOMA-Script class.

Example:

\documentclass[a4paper,
  listof=totoc% <- syntax changed! 
]{scrreprt} 
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% only needed with outdated TeX distributions
\usepackage{lmodern}
\usepackage[ngerman, english]{babel}
\usepackage[bmargin=4cm,tmargin=2cm,headheight=5cm]{geometry}
\usepackage{graphicx}

\usepackage{blindtext}% only for dummy text in the MWE

% KOMA-Script package for header and footer \usepackage[ manualmark,% or automark for running header entries headsepline, %plainheadsepline% headsepline on plain pages, too ]{scrlayer-scrpage}

\usepackage{hyperref}% load as last package

% header and footer \clearpairofpagestyles \ihead{\raisebox{-0.1\height}[0pt][0pt]{\includegraphics[scale=0.07]{example-image}}} \ohead {Example entry}% or \ohead{\headmark} for running header entries \cfoot{\pagemark}

\setcounter{secnumdepth}{\subsubsectionnumdepth} \setcounter{tocdepth}{\subsubsectiontocdepth}

\begin{document}

\begin{titlepage} \includegraphics[scale=.2]{example-image}\par\vspace{4cm} % put here your logo \vfill \centering \usekomafont{disposition}{\Huge Titlepage} \vfill \end{titlepage}

\addchap{Abstract} \Blindtext[2] \addchap{Einverständniserklärung} \Blindtext[2]

\tableofcontents \blinddocument \blinddocument

\end{document}

enter image description here

Additional remarks:

Do not use obsolete KOMA-Script options. I have replaced the outdated option by listof=totoc.

Use \addchap for unnumbered chapters with TOC (and header) entries. Use \addchap* for unnumbered chapters without TOC and header entries.

Load package hyperref after the other packages.

esdd
  • 85,675
2

I dont have your logo and yours input chapters. So I put here my logo e some text from \lipsum package.

\documentclass[a4paper, liststotoc]{scrreprt} 
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{lmodern}
    \usepackage[ngerman, english]{babel}
    \usepackage[bmargin=4cm,tmargin=2cm,headheight=5cm]{geometry}

\usepackage{graphicx} \usepackage{lipsum}

\usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{}

\fancyhead[L]{\raisebox{-0.1\height}[0pt][0pt]{\includegraphics[scale=0.1]{logoRS.png}}} % put here your logo \fancyhead[R]{\raisebox{0.2\height}[0pt][0pt]{R. Krupp - \textsl{\texttt{Statistics}}}} \fancyhead[C]{\raisebox{0.2\height}[0pt][0pt]{\textbf{\thepage}}} \renewcommand\headrulewidth{0.3pt} % 0.0pt if no line in the heather \renewcommand\footrulewidth{0pt}

\begin{document} \thispagestyle{empty}
\begin{titlepage} \includegraphics[scale=.5]{logoRS.png}\par\vspace{4cm} % put here your logo \centering \vspace{4cm} {\fontfamily{lmss}\selectfont {\huge\textbf{aWall Best Practice REST-API}\par} \vspace{1cm} {\huge\textbf{Projektbericht IP5}\par} } \vspace{2cm} \begin{table}[h] \begin{center} \begin{tabular}{lll} \textbf{Autoren}:&Cyril Kym, Remo von Arx\ &\ &\ \textbf{Hochschule:}&Hochschule für Technik\ \textbf{Studiengang:}&Informatik - Profilierung iCompetence\ \textbf{Betreuender Dozent:}&Prof. Martin Kropp\ \textbf{Auftraggeber:}&Martin Kropp, aTouch Dynamics GmbH \ &\ &\ & Brugg, 17. Januar 2022 \end{tabular} \end{center} \end{table} \vspace{1cm} {\large \par} \end{titlepage} \chapter{Test} \thispagestyle{fancy} %comment if you dont want heather on the first psge of chapter \lipsum[1-20]

\end{document}

enter image description here

Update If you dont want to repeat \thispagestyle{fancy} after each page correct the code in this way:

\newcommand{\chpt}[1]{\chapter{#1}\thispagestyle{fancy}}

\begin{document} \thispagestyle{empty}
...

\chpt{First chapter}
    \lipsum[1-20]
\chpt{Second chapter}
  \lipsum[21-45]

\end{document}

  • thanks for your input! it seems to work somewhat, but now the page numbers disappeared. What do I need to do, to let them reappear? – Remo Nov 14 '21 at 22:26
  • With this I need to add \thispagestyle{fancy} to every chapter? Is there no more convient way? Also the header disappears whenever I do a \pagebreak{} – Remo Nov 14 '21 at 22:34
  • 1
    @Remo No. If you want page number and heather on each page you must comment or delete the line of code before \lipsum[1-20]. – Raffaele Santoro Nov 14 '21 at 22:42
  • I just updated my source. Two issues; header just appears on the second page of each chapter. Also, I removed the line you've mentioned, as soon as the header appears, the page number is gone... For reproducing, try copy the abstract chapter – Remo Nov 14 '21 at 22:57
  • 1
    @ Remo Here you have anything you want (no repetition of commads after each chapter): \newcommand{\chpt}[1]{\chapter{#1}\thispagestyle{fancy}}

    \begin{document} \thispagestyle{empty} ...

    \chpt{First chapter} \lipsum[1-20] \chpt{Second chapter} \lipsum[21-45]

    \end{document}

    – Raffaele Santoro Nov 15 '21 at 00:01
  • 1
    By default chapter pages use page style plain . Only for KOMA-Script classes: if chapter pages should use a different style, redefine \chapterpagestyle, eg. \renewcommand{\chapterpagestyle}{fancy}. – esdd Nov 15 '21 at 08:34
  • @RaffaeleSantoro See my updated sources and image. This is what I get, still no header on the first page of chapters, also no page number, once the header is printed... What do I do wrong? I'm struggling, this can't be this hard, right? – Remo Nov 15 '21 at 08:46
  • Thanks @esdd, I'll try your approach as well! – Remo Nov 15 '21 at 08:46