TransWikia.com

Why are there on certain pages no headings?

TeX - LaTeX Asked on May 13, 2021

I am wondering why the chapter is not written down on the heading (as I marked red). I guess it has something to do with section*{}. Does anyone know how to fix this?

enter image description here
enter image description here

This is my code:

documentclass[11pt,a4paper,twoside]{article}
usepackage{setspace}
usepackage{titlesec}
usepackage{tabularx}
newcolumntype{C}{>{centeringarraybackslash}X}
usepackage[table]{xcolor} % F�r farbige Tabellenzellen
usepackage{colortbl} 
titleformat*{section}{normalfonthugebfseries}
titleformat*{subsection}{normalfontLargebfseries}
titleformat*{subsubsection}{largebfseries}
titleformat*{paragraph}{normalsizebfseries}
newcounter{tblerows}
expandafterletcsname c@tblerowsendcsnamerownum
usepackage{tablefootnote}
usepackage[sort&compress]{natbib}
usepackage{footnote}
setcitestyle{square}
usepackage{graphicx}
usepackage[ngerman]{babel}
usepackage{amsmath}
usepackage{upgreek}
usepackage{ragged2e}
usepackage{subcaption}
usepackage{supertabular}
usepackage{float}
usepackage{lmodern}
usepackage{times}
usepackage{mathptmx}         
usepackage{amssymb}
usepackage{amsbsy}
usepackage{amsfonts}
usepackage{amstext}
usepackage{lipsum}                 % Erzeugen von Blindtext
usepackage{booktabs}               % huebsche Tabellen % Subfigures
usepackage{xcolor}                 % Farben
usepackage{booktabs}               % hübsche Tabellen
usepackage{multirow}
usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm]{geometry}
usepackage{hyperref}
setcounter{secnumdepth}{5}
setcounter{tocdepth}{5}
usepackage[nottoc]{tocbibind}
usepackage{selinput}
usepackage[capitalize]{cleveref}
usepackage[T1]{fontenc}
newcommand*{quelle}[1]{parraggedleftfootnotesize Quelle:~#1}
newcommand*{EigeneAbbildung}[1]{parraggedleftfootnotesize Eigene Abbildung~#1}
usepackage[headsepline,automark]{scrlayer-scrpage}
clearpairofpagestyles
ihead{rightmark}
ofoot{pagemark}
addtokomafont{pageheadfoot}{upshapebfseries}
addtokomafont{pagenumber}{bfseries}
KOMAoptions{onpsinit=setstretch{1}}
renewcommand*chaptermarkformat{}
renewcommand*chapterpagestyle{scrheadings}


RequirePackage{filecontents}
usepackage{listings}
usepackage{color} %red, green, blue, yellow, cyan, magenta, black, white
definecolor{mygreen}{RGB}{28,172,0} % color values Red, Green, Blue
definecolor{mylilas}{RGB}{170,55,241}

begin{document}
section*{Abstract}
fngf
newpage
dgdfbhdthnfghnrfgfgtfrdfvjdnlsedvglneas
end{document}

Thank you in advance!

2 Answers

article ordinarily uses the contents of title{...} and author{...} to serve as the running heads, and applies these when maketitle is issued. Since I don't see any of these in your example, the running heads are blank.

You can set the running heads you want by issuing the command

markboth{<left heading text>}{<right heading text>|

somewhere after begin{document}. If you want to change the values, simply issue another markboth command with the new values. If you are changing only the right-hand heading, you can use markright instead, with a single argument.

Answered by barbara beeton on May 13, 2021

You are using

usepackage[headsepline,automark]{scrlayer-scrpage}

With the twosided article classs option automark does the same as

automark[subsection]{section}

So each section command (without star) sets a left mark and clears the right mark and each subsection (without star) sets a right mark.

So, with

clearpairofpagestyles
ihead{rightmark}
ofoot*{pagemark}% <- changed to get the page number on plain pages too

only (non-starred) subsections will get header entries.

Example:

documentclass[11pt,a4paper,twoside]{article}
usepackage{lipsum}% only for dummy text
usepackage{setspace}

usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm,
  headheight=13.6pt% <- added to avoid the warnings regarding the head height
]{geometry}
usepackage[T1]{fontenc}

usepackage[headsepline,
  automark,% does the same as automark[subsection]{section} for twosided article class
  singlespacing=true% <- added
]{scrlayer-scrpage}
clearpairofpagestyles
ihead{rightmark}% do you want only subsections in page headers?
ofoot*{pagemark}% <- changed to get the page number on plain pages too
addtokomafont{pageheadfoot}{upshapebfseries}
addtokomafont{pagenumber}{bfseries}
%KOMAoptions{onpsinit=setstretch{1}}% replaced by option singlespacing=true

begin{document}
section*{Abstract}
lipsum[1-20]
section{Numbered section}
lipsum[21-40]
subsection{Numbered subsection}
lipsum[41-60]
end{document}

Unfortunately, I do not know/understand how the desired result should look like.

If there should be the sections in header on even pages and subsections in header on odd pages, you have to use

ihead{headmark}

Example:

documentclass[11pt,a4paper,twoside]{article}
usepackage{lipsum}% only for dummy text
usepackage{setspace}

usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm,
  headheight=13.6pt% <- added to avoid the warnings regarding the head height
]{geometry}
usepackage[T1]{fontenc}

usepackage[headsepline,
  automark,% does the same as automark[subsection]{section} for twosided article class
  singlespacing=true% <- added
]{scrlayer-scrpage}
clearpairofpagestyles
ihead{headmark}% <- changed: sections on even pages, subsections on odd pages
ofoot*{pagemark}% <- changed
addtokomafont{pageheadfoot}{upshapebfseries}
addtokomafont{pagenumber}{bfseries}
%KOMAoptions{onpsinit=setstretch{1}}% replaced by option singlespacing=true

begin{document}
section*{Abstract}
lipsum[1-20]
section{Numbered section}
lipsum[21-40]
subsection{Numbered subsection}
lipsum[41-60]
end{document}

If the sections should be in page header on both even and odd pages, you can use

ihead{leftmark}% <- changed: only sections in page header

Or you could replace option automark by macro automark[section]{section}.

Example:

documentclass[11pt,a4paper,twoside]{article}
usepackage{lipsum}% only for dummy text
usepackage{setspace}

usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm,
  headheight=13.6pt% <- added to avoid the warnings regarding the head height
]{geometry}
usepackage[T1]{fontenc}

usepackage[headsepline,
  %automark,% does the same as automark[subsection]{section} for twosided article class
  singlespacing=true% <- added
]{scrlayer-scrpage}
automark[section]{section}% <- added
clearpairofpagestyles
ihead{headmark}% <- changed
ofoot*{pagemark}% <- changed
addtokomafont{pageheadfoot}{upshapebfseries}
addtokomafont{pagenumber}{bfseries}
%KOMAoptions{onpsinit=setstretch{1}}% replaced by option singlespacing=true

begin{document}
section*{Abstract}
lipsum[1-20]
section{Numbered section}
lipsum[21-40]
subsection{Numbered subsection}
lipsum[41-60]
end{document}

Starred sections, subsections etc. do not set marks automatically. But you can use markboth and markright to do this manually.

For the starred section you could use

section*{Abstractmarkboth{MakeMarkcase{Abstract}}{MakeMarkcase{Abstract}}}

which sets the left and the right mark or

section*{Abstractmarkboth{MakeMarkcase{Abstract}}{}}
``` which sets the left mark and clears the right mark

Example:

``` latex
documentclass[11pt,a4paper,twoside]{article}
usepackage{lipsum}% only for dummy text
usepackage{setspace}

usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm,
  headheight=13.6pt% <- added to avoid the warnings regarding the head height
]{geometry}
usepackage[T1]{fontenc}

usepackage[headsepline,
  %automark,% does the same as automark[subsection]{section} for twosided article class
  singlespacing=true% <- added
]{scrlayer-scrpage}
automark[section]{section}% <- added
clearpairofpagestyles
ihead{headmark}% <- changed
ofoot*{pagemark}% <- changed
addtokomafont{pageheadfoot}{upshapebfseries}
addtokomafont{pagenumber}{bfseries}
%KOMAoptions{onpsinit=setstretch{1}}% replaced by option singlespacing=true

begin{document}
section*{Abstractmarkboth{MakeMarkcase{Abstract}}{MakeMarkcase{Abstract}}}
lipsum[1-20]
section{Numbered section}
lipsum[21-40]
subsection{Numbered subsection}
lipsum[41-60]
end{document}

Answered by esdd on May 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP