sard
sard

Reputation: 51

I get the page number two places and I don't know why

I want to have the page number corner of the header, however, in addition I get page number also at the bottom. How can I remove this, without removing the header as I do when I Use \thispagestyle{empty}?

This is my YAML, where I guess most of the commands are irrelevant, however, I include them in case they are:

---
title: ""

header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead[LO,RE]{}
- \fancyhead[RO,LE]{\thepage}
- \fancyfoot[LO,LE]{\includegraphics[width=1.5cm]{SDU_BLACK_RGB.png}}

- \usepackage{array,multirow,booktabs,mathtools,tabulary,xcolor}
- \usepackage[T1]{fontenc}
- \usepackage{caption}
- \usepackage[utf8]{inputenc}
- \let\belowcaptionskip\abovecaptionskip
- \let\oldmidrule\midrule
- \usepackage[labelfont=bf,textfont=md]{caption}
- \captionsetup{justification=raggedright,singlelinecheck=false}
- \usepackage[leftcaption]{sidecap}
- \usepackage{ctable}
- \usepackage[flushleft]{threeparttable}
- \usepackage{adjustbox}
- \usepackage{subcaption}
- \usepackage{graphicx}
- \usepackage[danish,english]{babel}
- \usepackage[capitalise]{cleveref}
 

output: 
  pdf_document:
fontsize: 12pt
linestretch: 1.5
geometry: "left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm"

This produce pages like this one with the page number two places.

Page

Upvotes: 0

Views: 70

Answers (1)

  • If you use \fancyhf{} instead of \fancyhead{} you can clear both head and foot at once.

  • There is an unrelated problem with your loading of cleveref. This is one of the new packages which need to be loaded after hyperref. As rmarkdown unhelpfully takes away from you the choice on when to load hyperref, you need to delay cleveref with \AtBeginDocument{\usepackage[capitalise]{cleveref}}

  • Don't load the same package multiple times (e.g. caption)

  • No need to load graphicx, xcolor and fontenc, rmarkdown automatically loads them

  • if your latex distribution isn't from the stone age, you don't need \usepackage[utf8]{inputenc}. And if your tex distribution is from the stone age, you also don't need, because rmarkdown automatically loads it


---
title: ""
output: 
  pdf_document:
    keep_tex: true
fontsize: 12pt
linestretch: 1.5
geometry: "left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm"
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhf{}
- \fancyhead[RO,LE]{\thepage}
- \fancyfoot[LO,LE]{\includegraphics[width=1.5cm]{example-image-duck}}
- \usepackage{array,multirow,booktabs,mathtools,tabulary}
- \let\belowcaptionskip\abovecaptionskip
- \let\oldmidrule\midrule
- \usepackage[labelfont=bf,textfont=md]{caption}
- \captionsetup{justification=raggedright,singlelinecheck=false}
- \usepackage[leftcaption]{sidecap}
- \usepackage{ctable}
- \usepackage[flushleft]{threeparttable}
- \usepackage{adjustbox}
- \usepackage{subcaption}
- \usepackage[danish,english]{babel}
- \AtBeginDocument{\usepackage[capitalise]{cleveref}}
---

test

Upvotes: 1

Related Questions