R Markdown中的align环境同时适用于docx和pdf输出吗? [英] Align environment in R Markdown which works for both docx and pdf output?

查看:88
本文介绍了R Markdown中的align环境同时适用于docx和pdf输出吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

在R Markdown中,添加类似LaTeX align的环境(带有或不带有方程式编号)的正确方法是什么,该环境将同时为docx和pdf输出进行编译和显示?

In R Markdown, what is the right way to add a LaTeX align-like environment (with and without equation numbering) which will compile and display for both docx and pdf output?

详细信息:

下面的选项1是我要处理的.但是我仍然希望具有方程式编号的选项,并且当我在docx和pdf输出之间移动时不放弃该功能.

Option 1 below is what I'm going with. But I'd still like the option to have equation numbering and not give up that functionality when I move between docx and pdf output.

这将在docx和pdf输出中进行编译和显示.万岁!但是,如果我想要方程式编号怎么办?

This compiles and displays in both docx and pdf output. Hooray! But what if I want equation numbering?

\[
\begin{aligned}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{aligned}
\]

这将不会编译为pdf或docx输出.

This will not compile for pdf or docx output.

\[
\begin{aligned*}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{aligned*}
\]

这些可为docx和pdf输出进行编译.但是这些仅显示在pdf输出中.

These compile for both docx and pdf output. But these only display in pdf output.

\begin{align}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{align}

\begin{align*}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{align}

这些将编译并显示为docx输出.但是这些甚至无法编译为pdf输出.

These will compile and display for docx output. But these will not even compile for pdf output.

\[
\begin{align}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{align}
\]

\[
\begin{align*}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{align*}
\]

推荐答案

以下对我有用:

---
output:
  bookdown::pdf_document2: default
  bookdown::word_document2: default
  bookdown::html_document2: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

\begin{equation*}
\begin{aligned}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{aligned}
\end{equation*}

\begin{align*}
 AR(p): Y_i &= c + \epsilon_i + \phi_i Y_{i-1} \dots \\
 Y_{i} &= c + \phi_i Y_{i-1} \dots
\end{align*}

我正在使用*-环境获取PDF中未编号的方程式.要获取编号方程,您应使用不带*添加标签.

I am using the *-environments to get unnumbered equations in PDF. To get numbererd equations, you should use the environments without * and add labels.

这篇关于R Markdown中的align环境同时适用于docx和pdf输出吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆