Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 更改窗口大小时重新缩放html文本_R_R Markdown - Fatal编程技术网

R 更改窗口大小时重新缩放html文本

R 更改窗口大小时重新缩放html文本,r,r-markdown,R,R Markdown,我有以下标准的.Rmd文件 --- title: "STARTSTARTSTART         ENDENDEND" date: "`r format(Sys.time(), '%d de %B, %Y')`" output: html_document --- This is an [R Markdown](http

我有以下标准的.Rmd文件

---
title: "STARTSTARTSTART         ENDENDEND"
date: "`r format(Sys.time(), '%d de %B, %Y')`"
output:
  html_document
---



This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. 

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*. 

```{r}
plot(cars)
```

Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Ctrl+Shift+K* to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
我们可以看到完整窗口形式的输出:

当我们减小窗口大小时,绘图会缩小,因此它仍然适合,而标题和文本字母保持相同的大小,单词之间的间距开始减小,直到创建一条新线来容纳所有内容


有什么方法可以使标题或任何其他HTML文本表现得像绘图一样,在页面缩小时保持结构并缩小比例吗?

我们可以使用自定义css样式来实现缩放:

---
---
    ```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
    ```
# Custom CSS
    ```{css, echo=FALSE}
h1 {
  font-size: 5.9vw;
}
h2 {
  font-size: 3.0vh;
}
p {
  font-size: 2vmin;
}
    ```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

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:

    ```{r cars}
summary(cars)
    ```

## Including Plots

You can also embed plots, for example:

    ```{r pressure, echo=FALSE}
plot(pressure)
    ```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
---
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
#自定义CSS
```{css,echo=FALSE}
h1{
字体大小:5.9vw;
}
氢{
字体大小:3.0vh;
}
p{
字体大小:2vmin;
}
```
##降价
这是一份R降价文件。Markdown是一种用于编写HTML、PDF和MS Word文档的简单格式语法。有关使用R标记的更多详细信息,请参阅。
当您单击**Knit**按钮时,将生成一个文档,其中包括文档中任何嵌入的R代码块的内容和输出。您可以像这样嵌入R代码块:
```{r cars}
摘要(车辆)
```
##包括情节
还可以嵌入打印,例如:
```{r压力,回波=假}
绘图(压力)
```
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
查看和了解有关在RMd中包含CSS和在CSS中基于视口的缩放的更多详细信息

如果要将输出的宽度固定为页面大小,可以通过固定主容器的宽度来实现。然后,我们应该能够在需要的位置使用手动换行符

---
title: "STARTSTARTSTART &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; ENDENDEND"
date: "`r format(Sys.time(), '%d de %B, %Y')`"
output:
  html_document
---
<!--- Change width options to apppropiate values for your desired page size-->
<style type="text/css">
.main-container {
  width: 20cm;
  max-width: 20cm;
  min-width: 20cm;
  margin-left: auto;
  margin-right: auto;
}
</style>

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

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

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:

    ```{r cars}
    summary(cars)
    ```

## Including Plots

You can also embed plots, for example:

    ```{r pressure, echo=FALSE}
plot(pressure)
    ```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

---
标题:“开始开始&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;结束”
日期:“`r格式(Sys.time(),'%d de%B,%Y')`”
输出:
html_文件
---
.主货柜{
宽度:20厘米;
最大宽度:20cm;
最小宽度:20cm;
左边距:自动;
右边距:自动;
}
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
##降价
这是一份R降价文件。Markdown是一种用于编写HTML、PDF和MS Word文档的简单格式语法。有关使用R标记的更多详细信息,请参阅。
当您单击**Knit**按钮时,将生成一个文档,其中包括文档中任何嵌入的R代码块的内容和输出。您可以像这样嵌入R代码块:
```{r cars}
摘要(车辆)
```
##包括情节
还可以嵌入打印,例如:
```{r压力,回波=假}
绘图(压力)
```
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。

即使这样做,当窗口大小改变时,换行符仍会出现在文本的不同点上。如何修复文本格式,使其不会发生?您必须将所有文本放入具有适当属性的
divs
,但如果您想实现此行为,我不确定HTML是否适合您。如果您希望基本上是静态输出,为什么不使用PDF呢?我知道从HTML打印到PDF实际上是保持Rmarkdown呈现文档完整性的最佳方法之一,但是正如您所说,您无法获得HTML的响应能力。这个视点链接太棒了,我也必须检查一下。我已经考虑了更多@daniellga:我认为通过调整主容器的宽度参数,你可以实现你想要的行为。我已经用标记代码顶部的相关部分更新了答案。添加自定义CSS
.fluid行。title{font size:5.9vw;}
允许标题文本大小响应屏幕大小