小编N0r*_*ert的帖子

是否有可能提高从RMarkdown的TikZ插入到Word文档的图像的分辨率?

我有简单的RMarkdown文档:

---
output:
  word_document: default
  html_document: default
---


```{r,engine='tikz', fig.ext = 'png'}
\begin{tikzpicture}
\path (0,0) node
(x) {Hello World!}
(3,1) node[circle,draw](y) {$\int_1^2 x \mathrm d x$};
\draw[->,blue]
(x) -- (y);
\draw[->,red]
(x) -| node[near start,below] {label} (y);
\draw[->,orange] (x) .. controls +(up:1cm) and +(left:1cm) .. node[above,sloped] {label} (y);
\end{tikzpicture}
```
Run Code Online (Sandbox Code Playgroud)

这是pgfmanual.pdf的17.11的例子.

如果我'png'改为'svg':HTML输出很棒

TikZ SVG中的SVG图像 - 看起来很棒

它用tikz引擎产生圆形和矩形.
但是,即使使用100%缩放,生成的图像在DOCX中看起来也很难看并且像素化:

docx中的TikZ图像 - 低分辨率

我试图改变fig.width,dpi,out.width但没有得到积极的结果.

对我来说最好的结果将是以下内容:获取具有TikZ代码中指定尺寸的高分辨率图像.

是否可以提高从TikZ插入Word文档的图像的分辨率?

更新1:@CL使用set pandoc dpi使用pandoc_args的建议解决方案不起作用.

更新2:@tarleb解决方案提议{r,engine='tikz', engine.opts …

docx tikz knitr r-markdown

6
推荐指数
1
解决办法
383
查看次数

如何强制 RMarkdown 文档中的 Tikz 显示西里尔文本?

下面是我的实验 RMarkdown 文档(名为tikz-cyrillic.Rmd):

---
title: "TikZ cyrillic test"
output:
  pdf_document:
    keep_tex: yes
    latex_engine: xelatex
    dev: tikz
  html_document: default
  word_document: default
---

```{r,engine='tikz', fig.ext = if (knitr:::is_latex_output()) 'pdf' else 'svg'}
\begin{tikzpicture}
\path (0,0) node
(x) {Hello World!}
(3,1) node[circle,draw](y) {$\int_1^2 x \mathrm d x$};
\draw[->,blue]
(x) -- (y);
\draw[->,red]
(x) -| node[near start,below] {???!} (y);
\draw[->,orange] (x) .. controls +(up:1cm) and +(left:1cm) .. node[above,sloped] {??????} (y);
\end{tikzpicture}
```
Run Code Online (Sandbox Code Playgroud)

它基于pgfmanual.pdf 的 17.11 中的示例

Gummi 使用TeXLive 和 XeTeX …

tikz knitr r-markdown

5
推荐指数
1
解决办法
859
查看次数

Why inclusion of external Rmd-file with latex equation environment leads to different DOCX output while using rmarkdown and bookdown?

Below is the simplest Rmd file which I'm knitting to MS Word document using latest RStudio:

---
output:
  word_document: default
  bookdown::word_document2: default
---

```{sh, echo=FALSE, comment=''}
cat ~/latex-test.Rmd
```
Run Code Online (Sandbox Code Playgroud)

The contents of ~/latex-test.Rmd are as follows:

Auto-numbered equation:

$$ f(x) = \sin(x) $$ 

---

LaTeX equation without label (using `\begin{equation}...\end{equation}`)

\begin{equation}
h(z) = \sinh(z)
\end{equation}

---

LaTeX equation with bookdown-supported label (using `\begin{equation}...(\#eq:label)\end{equation}`)

\begin{equation}
  f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k}
  (\#eq:binom)
\end{equation}

---

LaTeX equation with Xaringan-supported label (using `\begin{equation}...\label{label}\end{equation}`):

\begin{equation}
  g\left(k\right) …
Run Code Online (Sandbox Code Playgroud)

r docx knitr r-markdown bookdown

4
推荐指数
1
解决办法
44
查看次数

是否有可能使这个矢量化的MATLAB代码更快?

在我的程序中,我需要计算总和:

和.

我计算这个总和与新值2500倍Cz.

参数z可以是矢量.我编写了简单的for循环和矢量化版本代码,如下所示:

K = 200;
n_z = 40000;
C = ones(K,1); % an example, in real life the arey some coefficients (at next call will be new)
k = 0:K-1;
z = linspace(0, 2*pi, n_z); % at next call will be new

tic;
    my_sum_for = zeros(1, K);
    for i=1:n_z
       my_sum_for(i) = C' * tan(k' * z(i));
    end
toc; % Elapsed time is 1.820485 seconds.

tic;
     my_sum = C' * tan(k' * z); …
Run Code Online (Sandbox Code Playgroud)

matlab vectorization

1
推荐指数
1
解决办法
310
查看次数

标签 统计

knitr ×3

r-markdown ×3

docx ×2

tikz ×2

bookdown ×1

matlab ×1

r ×1

vectorization ×1