将 Latex class 和模板文件调整为 Rmarkdown 模板

Adapting Latex class and template file to an Rmarkdown template

我正在尝试改编一份非官方的南佛罗里达大学 Latex 文档 class 和模板文件,这些文件可从 http://shell.cas.usf.edu/~saito/grad/ into an Rmarkdown template similar to the thesisdown and huskydown packages. After playing with that for a while I was able to get a package that has a custom template (https://github.com/ailich/bulldown) and can be installed with remotes::install_github("ailich/bulldown"). The document will knit, but if I add any headers to the child documents (e.g. # Chapter 1) I get the error "! Undefined control sequence. l.49 \hypertarget". I've included a text file 获得,其中列出了我创建此 R package/template 所采取的步骤] 以及我必须对各种文件进行的编辑。有谁知道如何解决这个问题或为什么会发生?我对 Latex 不是很熟悉,所以我在调试时遇到了麻烦。我已经包含了一个转换后的 .tex 文档的示例,该文档在单击下面的“编织”后出现。

\documentclass[boldheadings,thrmdefs,bbm,ams]{USFDissertation}

%% Set basic information about the disseration
\title{My Dissertation Title}
\author{My Name}
\degree{Doctorate of Philosopy}
\department{Marine Resource Assessment}
\college{College of Marine Science}
\university{}
\majorprofessor{your advisor}{Ph.D.}
\committeemember{committee member 1}{Ph.D.}
\committeemember{committee member 2}{Ph.D.}
\committeemember{committee member 3}{Ph.D}
\committeemember{committee member 4}{Ph.D}
\keywords{keyword1}{keyword2}{keyword3}{keyword4}{keyword5}
\approvaldate{August 5, 2023}
\copyrightdate{2023}

%% Begin the document itself
\begin{document}

%% Make a title page
\maketitle

%% Maybe dedicate it to someone
\begin{dedication}
``My dedication''
\end{dedication}
%% Acknowlege your intellectual debts
\begin{acknowledgment}
``My acknowledgments''
\end{acknowledgment}
%% Insert a table of contents
\tableofcontents

%% Insert a table of tables -- comes before figures in the format.
\listoftables

%% Insert a table of figures
\listoffigures

%% Include an abstract
\begin{abstract}
``Here is my abstract''
\end{abstract}
%% begin the body of the dissertation
\dissertation

\hypertarget{title-of-my-first-chapter}{%
\chapter{Title of my first chapter}\label{title-of-my-first-chapter}}

The first thing

The second thing

The third thing

%% End of dissertation
\end{document}

这可以通过 "-r", "markdown-auto_identifiers"

来完成

可以在YAML中指定

output: 
  bulldown::thesis_pdf:
    pandoc_args: [
      "-r", "markdown-auto_identifiers"
      ]

或者在像 bookdown::pdf_book 这样的函数中使用 pandoc_args 参数

pandoc_args = c(pandoc_args, "--top-level-division=chapter", "-r","markdown-auto_identifiers")