Using Pandoc & LaTex to export to PDF: Header line should just include name, not file name or Header from file

I found this thread that shows how to use the frontmatter to tell Pandoc & LaTex what to do: Adding headers and footers using Pandoc - TeX - LaTeX Stack Exchange

---
title: Test
author: Author Name
header-includes: |
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead[CO,CE]{This is fancy}
    \fancyfoot[CO,CE]{So is this}
    \fancyfoot[LE,RO]{\thepage}
abstract: This is a pandoc test . . . 
...

I’ve installed TexLive (I’m on Linux Mint)

If I use this “Test” and “Author Name” show up, but not the header line.

If I delete some stuff so it looks like this:

---
header-includes: 
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead[CO,CE]{Name}
---

“Name” shows up in the header line (above the title) which is precisely what I want, but then there also appears the Header from the File (the title at the top of the file that comes after #).

I would like to just see my name at the top, and maybe the page number that appears at the bottom of the page in the PDF.

Any ideas?
Thanks!

Edit: I’ve managed to achieve this:
image

with this code:

header-includes: |
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhf[]{}
    \fancyhead[R]{Name \date{\today}}
    \fancyhead[C]{\thepage}
    \usepackage[a4paper, portrait, margin=1in]{geometry}
    \fontsize{12pt}{12pt}\selectfont
    \usepackage{setspace}
    \doublespacing
---

I don’t understand why the “\date{\today}}” isn’t appearing, but if I delete it, nothing works, so I’m leaving it in.

What I can’t figure out is how to center the whole thing. It’s too far on the left. Any ideas on that?
Thanks!

It’s a very long time since I’ve used LaTeX, but it being too far left is most likely due to your page setup being two-sided, and since this is the first page it leaves room near the center. If I’m correct then your second page will have the same amount of space on the left-hand side of the page.

In other words, you need to either change from a two-sided layout, or find where the page margins for your layout is defined, and change them.

The header on page 2 looks the same. Does that mean it’s not the issue with the two-sided layout?
Thanks!

Could be. You’ll still need to identify the page layout parameters and tweak these to your liking.

OK, thanks! Any idea how I would do that? Or a place I could look that up?

I solved this, so I have a better question:

How would I use this LaTex code to be applied to all notes that I wish to convert this way? I know there’s pandoc reference docs but I can’t get that to work with a Latex template.

This code seems to be working locally/per-note

---
header-includes: |
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhf[]{}
    \fancyhead[R]{My Name \date{\today}}
    \fancyhead[C]{\thepage}
    \usepackage[a4paper, portrait, margin=1in]{geometry}
    \fontsize{12pt}{12pt}\selectfont
    \usepackage{setspace}
    \doublespacing
    \newlength\FHoffset
	\setlength\FHoffset{1cm}
	\fancyheadoffset{\FHoffset}
---

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.