! Undefined control sequence. <argument> \mathindent in Rmarkdown

I am using rmarkdown to write my thesis. I have separated the thesis into different rmarkdown documents to make my work easy. Specifically, I have an introductions document, a literature review document and a methodology document. I then use a main rmarkdown document to combine all the documents into one output. My main document is as shown in the code below.

title: \textbf{Examining The Effect of Padding}
output:
  pdf_document:
    number_sections: TRUE
    keep_tex: TRUE
    fig_caption: TRUE
    latex_engine: xelatex
geometry: "left = 2.54cm, right = 2.54cm, top = 2.54cm, bottom = 2.54cm"
fontsize: 12pt
header-includes:
  - \usepackage{float}
  - \usepackage{sectsty}
  - \usepackage{paralist}
  - \usepackage{setspace}
  - \setstretch{2.0}
  - \usepackage{fancyhdr}
  - \usepackage{ragged2e}
  - \usepackage{lastpage}
  - \usepackage{dcolumn}
  - \usepackage[nottoc, numbib]{tocbibind}
  - \usepackage{amsmath}
  - \setlength{\mathindent}{0pt}
  - \usepackage{enumitem}
  - \renewcommand{\theequation}{\thechapter.\arabic{equation}}
documentclass: report
---


```{r setup, include=FALSE} 
knitr::opts_chunk$set(echo = TRUE)

\newpage

options(tinytex.verbose = TRUE)

\newpage

I have a problem in the methodology section where I am trying to write a series of equations in this section. My methodology sections is as shown below.

title: " "
output:
pdf_document:
number_sections: TRUE
keep_tex: TRUE
latex_engine: xelatex
geometry: "left = 2.54cm, right = 2.54cm, top = 2.54cm, bottom = 2.54cm"
fontsize: 12pt
classoption: fleqn
header-includes:

  • \usepackage{float}
  • \usepackage{sectsty}
  • \usepackage{setspace}
  • \setstretch{2.0}
  • \usepackage{ragged2e}
  • \setlength{\mathindent}{0pt}
  • \usepackage{enumitem}

\onehalfspacing
\normalsize
\justifying

Chapter Three

\vspace{-1em}

Methodology{-}

Introduction

| This section discusses the theory behind neural networks by deriving the back propagation algorithm. The section also discusses techniques used in convolution neural networks by describing how CNNs extract data from images. Specifically, this section focuses on major techniques used in CNNs such as filtering, strides, padding, pooling and batch normalization.

\vspace{-1em}
\begin{equation}
\begin{aligned}
\frac{\partial I_j^{(3)}}{\partial W_{ji}^{(3)}} = Y_i^{(2)} \quad \text{(Obtained from the partial derivative of equation 3.5 with respect to ( W_{ji} ))}
\label{eq:equation 3.12}
\end{aligned}
\end{equation}
\vspace{-1em}```

Trying t knit the document in main document raises the error ! Undefined control sequence.<argument> \mathindent. However I can run the methodology document on its own successfully