latex - ! Undefined control sequence. <argument> mathindent in Rmarkdown - Stack Overflow

I am using rmarkdown to write my thesis. I have separated the thesis into different rmarkdown documents

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 Paddin}
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)
```

```{r intro, child = 'introduction.Rmd'}
```

\newpage

```{r litret, child = 'literature.Rmd'}
```

```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```

\newpage

```{r methods, child = 'methodology.Rmd'}
```

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.

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 Paddin}
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)
```

```{r intro, child = 'introduction.Rmd'}
```

\newpage

```{r litret, child = 'literature.Rmd'}
```

```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```

\newpage

```{r methods, child = 'methodology.Rmd'}
```

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.

Share Improve this question edited Nov 17, 2024 at 6:20 Confusion Matrix asked Nov 17, 2024 at 4:28 Confusion MatrixConfusion Matrix 1183 silver badges15 bronze badges 1
  • Can you show the intermediate .tex files? – samcarter_is_at_topanswers.xyz Commented Nov 17, 2024 at 10:36
Add a comment  | 

1 Answer 1

Reset to default 2

The methodology chapter on its own isn't using documentclass: report. Apparently that document class doesn't support the \mathindent setting.

To fix this, just delete the line

  - \setlength{\mathindent}{0pt}

from the main document.

If that messes up your desired formatting, you might want to read this discussion: https://tex.stackexchange/questions/50233/positioning-of-equations . For example, you might want

documentclass: report
classoption: fleqn

to make all your equations be flushed left.

By the way, the header includes in methodology.Rmd are ignored when you compile the main document, so you may find you need to copy some others there when you put together the full document.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745638604a4637550.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信