Search code examples
latexmarkdownpandoc

Why is swedish letters not working with fancyhdr for laTex pandoc conversion?


Does anyone know why this decoding error happens when I try to convert a markdown file to pdf? Everything works fine except when I use Swedish letters in fancyhdr. If i remove the letter 'å' it works (the letter is in the YAML below).

pandoc-script:

pandoc  main_temp.md default.yaml  -o main.pdf --bibliography library.bib -V lang=sv 

Error:

UTF-8 decoding error in default.yaml at byte offset 454 (e5).
The input must be a UTF-8 encoded text.

my YAML:

---
start-page: 2 # start pagenumbering on page 2
geometry: #
- top=2cm
- bottom=2cm
- left=2.4cm
- right=2.4cm
pagesize: a4
indent: true
font: Times New Roman
fontsize: 12pt
header-includes:
- \usepackage{setspace}
- \setstretch{1.5}

- \usepackage{fancyhdr} # for header and footer (ej sv tecken)
- \pagestyle{fancy} # not sure what this is
- \fancyhead[LO,LE]{myname}
- \fancyfoot[CO,CE]{Perspektiv pa politik 2020} 
- \fancyfoot[LE,RO]{\thepage} # not sure what this is.

# Change size of header:
- \usepackage{sectsty}
- \sectionfont{\small}

# Change spacing left/before/after header:
- \usepackage{titlesec}
- \titlespacing*{\section}{0pt}{5pt}{2pt} #{left}{before}{after}  
---
````


Solution

  • For some reason I missed that my files where ANSI and not UTF-8. Notepad first showed UTF-8 for some reason. Probably user error :)

    This line fixed my problem:

    - \usepackage[utf8]{inputenc}