![](/img/trans.png)
[英]Using R, RStudio Knit to PDF, how to pass custom flags to the "pdflatex" command such as -interaction=nonstopmode
[英]Using R, RStudio Knit to PDF, how to pass tilde to prevent line wrapping "Table~\ref{table:data-from-phone}"?
在 Latex 中,通常使用“~”来引用标签以将数字附加到标签上,例如 Figure 或 Table。
https://tex.stackexchange.com/questions/227285/problems-with-tilde-and-line-break/227296展示了一个例子。
一个完整的示例可以在这里找到:
http://md5.mshaffer.com/WSU_STATS419/stackoverflow/tilde/
在 Rmd 文件中, http://md5.mshaffer.com/WSU_STATS419/stackoverflow/tilde/reference-tilde.Rmd ,
我有以下几点:
---
title: "Untitled"
output:
pdf_document:
keep_tex: true
number_sections: true
latex_engine: pdflatex
---
\section{My Section Name}
\label{sec:my}
Below you will find Equation~\ref{eq:my-model}.
\begin{equation}
\label{eq:my-model}
Y_{jt} = \alpha + \beta X_{jt} + \upsilon_{j} + \varepsilon_{jt} ,
\end{equation}
\subsection{My sub section}
\label{sec:mysub}
For more information, please refer to Section~\ref{sec:my}.
请注意“~”波浪号的使用,如基本 Latex 用法中所述。
当我点击 Knit-PDF 时,它输出了一些我没想到的东西:
http://md5.mshaffer.com/WSU_STATS419/stackoverflow/tilde/reference-tilde.pdf
由于我选择了“keep_tex”,所以可以查看.TEX文件
http://md5.mshaffer.com/WSU_STATS419/stackoverflow/tilde/reference-tilde.tex可以在这里在线查看: http : //md5.mshaffer.com/WSU_STATS419/stackoverflow/tilde/reference-tilde.tex。文本
它似乎已经用文本版本替换了波浪号:
\begin{document}
\maketitle
\section{My Section Name}
\label{sec:my}
Below you will find Equation\textasciitilde{}\ref{eq:my-model}.
\begin{equation}
\label{eq:my-model}
Y_{jt} = \alpha + \beta X_{jt} + \upsilon_{j} + \varepsilon_{jt} ,
\end{equation}
\subsection{My sub section}
\label{sec:mysub}
For more information, please refer to
Section\textasciitilde{}\ref{sec:my}.
\end{document}
我该如何纠正这种情况?
如何让 Latex 按预期呈现?
如何让我的波浪号作为间隔符回来?
Unicode 不间断空间应该可以工作。 或者 pandoc 甚至将 markdown 中的 HTML 实体解析为正确的内容,例如
echo ' foo' | pandoc -t latex
~foo
如果您必须在 Markdown 中包含一些难以解析的 LaTeX,您可以使用通用的原始属性,例如:
```{=latex}
my LaTeX
```
根据this question and answer ,您可以尝试用“\\~”或“\\sim”替换波浪号,看看哪个有效。
由于您保留了 .tex 文件,因此即使 #1 不起作用,您也可以始终使用真正的波浪号搜索+替换\\textasciitilde{}
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.