R中的MiKTeX-如何对齐结果方程

时间:2019-01-28 03:54:31

标签: r latex r-markdown

我在R中使用MiKTeX。使用此代码,

$$
1 - p(X) = 1 - \frac{\mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\

&= \frac{1 + \mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} - \frac{\mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\

&= \frac{1 + \mathrm{e}^{\beta_0 + \beta_1 X} - \mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\

&= \frac{1}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}}
$$

结果:

enter image description here 如何将所得方程与每行的'='线对齐?

1 个答案:

答案 0 :(得分:2)

您需要使用

mysqli_select_db($con,"items");

// Get the offset value
$offset = empty($_GET['offset']) ? 0 : $_GET['offset']

$sql="SELECT * FROM items Limit 1, $offset"; // pass the offset value to LIMIT query
$result = mysqli_query($con,$sql);

while($row = mysqli_fetch_assoc($result))
    $rows[] = array_map('utf8_encode', $row);

header('Content-Type: application/json');
echo json_encode($rows);

构造,在每个\begin{align*} ... \end{align*} 的左侧放置一个&

=

enter image description here

此外,When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: \begin{align*} 1 - p(X) &= 1 - \frac{\mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\ &= \frac{1 + \mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} - \frac{\mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\ &= \frac{1 + \mathrm{e}^{\beta_0 + \beta_1 X} - \mathrm{e}^{\beta_0 + \beta_1 X}}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \\ &= \frac{1}{1 + \mathrm{e}^{\beta_0 + \beta_1 X}} \end{align*} 内一般不能有任何空白行。