简体   繁体   English

在R Markdown中创建可填充的彩色文本框(PDF)

[英]Creating a fillable and colored textbox in R Markdown (PDF)

I'm trying to create a markdown, where the text that accompanies the plots and tables are in dark blue boxes, like the image down below: 我正在尝试创建一个markdown,其中情节和表格随附的文本在深蓝色框中,就像下面的图像一样: 在此处输入图片说明

I've tried looking at this solution , but I wasn't able to reproduce the box at all, and certainly not in a colored version. 我尝试过查看此解决方案 ,但是我根本无法复制该盒子,当然也不能复制彩色版本。 Does anyone have a good idea on how to do this in markdown? 有谁对如何在降价促销中有个好主意吗?

---
title: "Untitled"
author: "Test"
date: "22/6/2018"
output: pdf_document
---

```{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.

\begin{Form}
    \TextField[width = 10cm, height = 10cm]{This is the textbox.}
    I would like a dark blue textbox with white writing
\end{Form}

The \\TextField command takes some optional arguments to define color and default text: \\TextField命令采用一些可选参数来定义颜色和默认文本:

---
output: 
  pdf_document:
    keep_tex: yes
---

\begin{Form}
    \TextField[width = 10cm,%
               height = 3cm,%
               multiline=true,%
               bordercolor = 0 0 0.5,%
               backgroundcolor = 0 0 0.5,%
               color = 1 1 1,%
               value = {%
                          This is the textbox.
                          I would like a dark blue textbox with white writing
                        }%
               ]{}
\end{Form}

This produces: 这将产生:

在此处输入图片说明

One can edit the \\TextField to contain multi-line text, but I am not able to set a value with multiple lines. 可以编辑\\TextField以包含多行文本,但是我无法设置多行value Using \\string\\n (cf https://tex.stackexchange.com/questions/416218/how-to-add-line-breaks-to-hyperref-pdf-form-textfield ) does not work for me. 使用\\string\\n (cf https://tex.stackexchange.com/questions/416218/how-to-add-line-breaks-to-hyperref-pdf-form-textfield )对我不起作用。 This might depend on the PDF viewer, though. 不过,这可能取决于PDF查看器。 I am using Evince. 我正在使用Evince。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM