3

在 Latex 中,通常使用“~”来引用标签,以保留附在标签上的数字,例如图形或表格。

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}

我该如何纠正这种情况?

如何让乳胶按预期呈现?

如何让我的波浪号作为间隔号回来?

4

2 回答 2

4

一个 unicode 不间断空间应该可以工作。或者 pandoc 甚至将 markdown 中的 HTML 实体解析为正确的东西,参见例如

echo ' foo' | pandoc -t latex

~foo

如果您必须在降价中包含一些难以解析的 LaTeX,您可以使用通用的原始属性,例如:

```{=latex}
my LaTeX
```
于 2020-11-06T10:34:24.793 回答
0
  1. 根据this question and answer,您可以尝试用“\~”或“\sim”替换波浪号,看看哪个有效。

  2. 由于您保留了 .tex 文件,因此\textasciitilde{}即使 #1 不起作用,您也可以始终搜索 + 替换为真正的波浪号。

于 2020-11-05T16:39:03.773 回答