【问题标题】:Adapting Latex class and template file to an Rmarkdown template使 Latex 类和模板文件适应 Rmarkdown 模板
【发布时间】:2021-12-29 10:56:24
【问题描述】:

我正在尝试将可从http://shell.cas.usf.edu/~saito/grad/ 获得的非官方南佛罗里达大学乳胶文档类和模板文件改编为类似于thesisdownhuskydown 包的Rmarkdown template。在玩了一段时间之后,我得到了一个包含自定义模板 (https://github.com/ailich/bulldown) 并且可以使用 remotes::install_github("ailich/bulldown") 安装的包。该文档将编织,但如果我向子文档添加任何标题(例如#第 1 章),我会收到错误“!未定义的控制序列。l.49 \hypertarget”。 I've included a text file 列出了我创建此 R 包/模板所采取的步骤以及我必须对各种文件进行的编辑。有谁知道如何解决这个问题或为什么会发生?我对 Latex 不是很熟悉,所以我在调试时遇到了麻烦。我已经包含了一个转换后的 .tex 文档的示例,该示例在单击下面的“knit”后出现。

\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}

【问题讨论】:

  • 你能显示你的中间 .tex 文件吗?
  • @samcarter_is_at_topanswers.xyz,感谢您的建议。我刚刚将它添加到原始帖子中。
  • 一个问题似乎是在转换为 tex 的过程中,使用了 \hypertarget{...}{...} 的(废话)构造。这将需要 hyperref 包,但您的课程似乎不适用于此包
  • 也许可以尝试stackoverflow.com/questions/52341046/… 删除这个无意义的代码
  • @samcarter_is_at_topanswers.xyz,谢谢。你知道pandoc -r markdown-auto_identifiers -w latex test.md -o test.tex 会去哪里吗?我在想也许该语句的一部分可以包含在 Rmarkdown 文档中的 pandoc_args YAML 字段中,或者作为对 bookdown::pdf_book 的调用中的 pandoc_args 参数,当前指定为 pandoc_args = c(pandoc_args, "--top-level-division=chapter")

标签: r latex r-markdown pandoc bookdown


【解决方案1】:

这可以通过"-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")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-27
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    相关资源
    最近更新 更多