我正在使用 R Markdown 准备一份科学文章手稿。我的 R Markdown 文件首先由 knitr 转换为 Markdown,然后由 pandoc 转换为 LaTeX 代码。
在 LaTeX 中,~
字符用于指示不间断空格。 It is considered good style被一些期刊使用~
\ref
前面的字符或 \cite
.例如,像 Section~\ref{...}
这样的 LaTeX 代码和 Figure~\ref{...}
或者更确切地说 Sect.~\ref{...}
和 Fig.~\ref{...}
是我的日记所期待的。
尝试使用 R Markdown 生成尽可能接近期刊指南的 LaTeX 代码,我尝试使用 Sect.~\ref{...}
,但这会转换为 Sect.\textasciitilde{}\ref{...}
通过潘多克。
如何防止 pandoc 逃离 ~
字符到 \textasciitilde{}
获得有效的LaTeX?
最佳答案
我在 pandoc 手册( 1 , 2 )中发现使用 Sect.\ \ref{...}
解决问题:
A backslash-escaped space is parsed as a nonbreaking space. It will appear in TeX output as
~
and in HTML and XML as\ 
or\
.
Sect.\ \ref{...}
在 Markdown 文件中编译为 Sect.~\ref{...}
在 LaTeX 文件中。
关于r - 如何使用 R markdown 和 pandoc 防止在 LaTeX 文档中转义〜(波浪号)字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60297933/