3

I'm writing my thesis with bookdown. But the bookdown format doesn't suit that of my university's requirement. I tried various solutions provided in twerking the YAML metadata content, yet not able to satisfy the needed requirement.

I further read about the possibility of using a LaTeX template to override the pandoc template in bookdown. I obtain my university's LaTeX template and its' .sty file and followed the discussions here: bookdown with specific latex template. But I get the error message: ! LaTeX Error: Missing \begin{document}

Below is the YAML metadata in my index file:

---
title: "Role of Public Expenditure"
subtitle: 
- "By"  
- "Blaise Saanuo"  
- "(BSc. Economics & Business Administration, Management)"
author: 
- "A thesis submitted to the Department of Accounting and Finance, Kwame Nkrumah University of Science and Technology, Kumasi in partial fulfilment of the requirements for the award degree of"
- "MASTER OF PHILOSOPHY IN BUSINESS ADMINISTRATION"
- "[FINANCE]"
date: "June, 2020"
output: 
  bookdown::gitbook:
    css: style.css
    split_by: chapter
    config:
      toc:
        collapse: section
        before: |
          <li><a href="...">My MPhil Thesis Report</a></li>
          <li><a href="...">Blaise Boya Kuubetertii Saanuo</a></li>
        after: |
          <li><a href="...">Proudly published with bookdown</a></li>
      toolbar:
        position: fixed
      search: yes
      download: no
      edit: no
      fontsettings:
        theme: white
        family: sans
        size: 2
      sharing:
        facebook: yes
        twitter: yes
        github: yes
        all: false
  bookdown::pdf_book:
    includes:
      in_header: preamble.tex
    template: null
    keep_tex: yes
    latex_engine: xelatex  
    citation_package: none
    pandoc_args: --top-level-division=chapter 
mainfont: "Times New Roman"
fontsize: 12pt
papersize: a4
linestretch: 1.5
toc: true
toc-depth: 3
lof: True
lot: True
site: bookdown::bookdown_site
documentclass: book 
classoption: knustthesis.tex 
bibliography: ["book.bib", "packages.bib"]
csl: harvard-educational-review.csl
link-citations: yes
geometry: "left=4cm, right=2.5cm, top=2.5cm, bottom=2.5cm"
---

The content of my university's LaTeX template is stored in the file knustthesis.tex, which I set as my classoption in the YAML metadata. Below is the content:

\documentclass[a4paper,12pt, oneside]{book}
\usepackage{knustthesis}



\begin{document}


\include{titlepage}


\frontmatter
%\pagenumbering{roman}
\include{A1-declaration}
\include{A2-dedication}
\include{A3-acknowledgement}
\include{A4-abstract}

\addcontentsline{toc}{chapter}{Declaration}
\addcontentsline{toc}{chapter}{Dedication}
\addcontentsline{toc}{chapter}{Acknowledgement}
\addcontentsline{toc}{chapter}{Abstract}


\tableofcontents

\newpage
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}

\newpage
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}

\mainmatter
\include{01-intro}
\include{02-literature}
\include{03-method}
\include{04-application}
\include{05-summary}

%\include{ref}


\backmatter

\bibliographystyle{harvard-educational-review}
\bibliography{reference}
\addcontentsline{toc}{chapter}{References}

\include{07-appendices}

\end{document}

The content of the .sty file are as below:

\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[left=4.00cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry} 
\newtheorem{definition}{Definition}
\newtheorem{example}{Example}[section]
\newtheorem{theorem}{Theorem}[section]
\usepackage{enumerate}
\usepackage{tabularx}
\usepackage{placeins}
\setlength{\parindent}{1.5cm}
\pagestyle{plain}
\usepackage{tocloft}

\usepackage{setspace, latexsym}
\doublespacing
\usepackage[round]{natbib}
%\bibpunct{(}{)}{;}{a}{,}{,}

\renewcommand{\chaptername}{CHAPTER}{\Large}
\usepackage{titlesec}

\titleformat{\chapter}[display]
{\normalfont\Large\bfseries\centering\Numberstring{section}}{\chaptertitlename\ \thechapter}{20pt}{\Large}

\titlespacing*{\chapter}{0pt}{0pt}{0em}
\renewcommand{\baselinestretch}{1}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}




\renewcommand{\bibname}{REFERENCES}

Yihui recommended I use remotes::install_github('rstudio/rmarkdown') but it did not help.

Would be very much glad if I could be helped to replace the pandoc template with that of my university's LaTeX template. Thank you in advance for your aid.

Azaaviela
  • 71
  • 6
  • It is nearly impossible to help you without you providing us a minimal reproducible example (you may post it in a Github repo if you know how). – Yihui Xie Dec 12 '19 at 19:02
  • @YihuiXie, now I am at sea about this reproducible example. May I get a link to a sample reproducible example or how to post to Github repo. Thank you. – Azaaviela Dec 13 '19 at 13:45
  • Delete any content in your document(s) that shouldn't be shared, make sure the problem is still reproducible, zip all files, and share the zip archive. There are numerous ways to share files (e.g. Dropbox). You could also file an issue to https://github.com/rstudio/bookdown/issues and upload the zip file there. – Yihui Xie Dec 13 '19 at 16:01
  • I have attached a sample of what I am trying to achieve by this question at . I created it using MS Word. I still stand in need of assistance. Thank you in anticipation. – Azaaviela Jan 27 '20 at 11:54

0 Answers0