这些表格周围的反引号(`)如何逃逸? [英] How can the backticks (`) printed around these tables be escaped?
问题描述
在并排对齐多个表中,用户询问有关对齐的问题表,(提供的(非常好)答案)涉及在一块中使用乳胶,并将结果按原样返回给LaTeX.这对于该用户的问题是正确的.
In Align multiple tables side by side, a user asks about aligning tables, and the (very good) answer provided involves using latex in a chunk with the results returned as is to LaTeX. This is correct for that users question.
我很好奇是否可以轻松地将其转换为嵌入式(即非分块)解决方案.
I am curious if this can be easily converted into an inline (i.e. not in chunk) solution.
\begin{table}[!htb]
\begin{minipage}{.5\linewidth}
\caption{}
\centering,
`r t1`,
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\caption{},
`r t2`,
\end{minipage}
\end{table}
这几乎是成功的,但是从R调用对象所需的反引号最终也被打印到输出中.我错过了什么?是否可以摆脱LaTeX的反引号,但不能摆脱R进程的反引号?
This is almost successful, however the backticks which are required to call the objects from R, end up also being printed to the output. What have I missed? Is it possible to escape the backticks from LaTeX, but not from the R process?
更新: 要求重现性后,请参见我的解决方案的完整降价以及我链接并引用的其他答案,以及输出pdf的屏幕截图
Update: After requests for reproducibility, please see the full markdown of my solution combined with the other answer I linked and referred to as well as a screencap of the output pdf
推荐答案
反引号正确解释,如以下示例所示:
The backticks are interpreted correctly, as is shown in the following example:
---
title: 'A title'
author: 'An author'
date: 'A date'
output:
pdf_document
---
```{r include=FALSE}
myvar1 <- 5 * cos(pi / 3)
myvar2 <- 10 * sin(pi / 6)
```
`myvar1` is `r myvar1`; `myvar2` is `r myvar2`.
\begin{table}[!htb]
\begin{minipage}{.5\linewidth}
\caption{}
\centering
`r myvar1`
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\caption{}
`r myvar2`
\end{minipage}
\end{table}
在您的示例中,也不会打印反引号,但是您将保留作为代码一部分的,
.您可能会误以为,
看起来像反引号.
In your example the backticks would also not be printed, but the ,
s you left as part of your code will be. You may have been mistaken by the ,
s looking like backticks.
这篇关于这些表格周围的反引号(`)如何逃逸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!