【发布时间】:2021-02-09 12:30:20
【问题描述】:
我正在尝试使用 RMarkdown 将文档编织成 pdf 文档。我想默认删除部分编号。我认为number_section:FALSE 会这样做,但事实并非如此。我已精简为 MWE,但我仍在获取部分编号。
在编织的report.tex 文件中,我使用{-} 专门标记为没有编号的部分标记为\section*{...},而其他部分标记为\section{...},这就是您完成编号的方式一些 LaTeX 中的部分,但是我希望将所有部分编织为\section*{...},而不必在每个部分(或子部分)中指定{-}。
我正在使用 pandoc 版本2.11.2、RStudio 版本1.4.1103 和R 版本4.0.3
这是我的源文件:
report.Rmd:
---
output:
pdf_document:
template: template.tex
keep_tex: TRUE
number_sections: FALSE
---
# Abstract {-}
# Introduction
## A Subsection
# A Second Section
template.tex:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
$body$
\end{document}
RMarkdown 输出中的 pandoc 调用显示为(我添加了换行符以使其更易于阅读),请注意它不包含 --number-sections,它通常用于告诉 pandoc 强制编号,默认情况下 pandoc 应该不要给他们编号。
"C:/Program Files/RStudio/bin/pandoc/pandoc"
+RTS -K512m -RTS report.utf8.md
--to latex
--from markdown+autolink_bare_uris+tex_math_single_backslash
--output report.tex
--lua-filter "C:\Users\MichaelBarrowman\Documents\R\R-4.0.3\library\rmarkdown\rmarkdown\lua\pagebreak.lua"
--lua-filter "C:\Users\MichaelBarrowman\Documents\R\R-4.0.3\library\rmarkdown\rmarkdown\lua\latex-div.lua"
--self-contained
--template template.tex
--highlight-style tango
--pdf-engine pdflatex
这将编织到以下report.tex 文件:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\hypertarget{abstract}{%
\section*{Abstract}\label{abstract}}
\addcontentsline{toc}{section}{Abstract}
\hypertarget{introduction}{%
\section{Introduction}\label{introduction}}
\hypertarget{a-subsection}{%
\subsection{A Subsection}\label{a-subsection}}
\hypertarget{a-second-section}{%
\section{A Second Section}\label{a-second-section}}
\end{document}
呈现为report.pdf,如下所示:
【问题讨论】:
标签: r latex r-markdown pandoc