我正在使用
quarto
准备 Beamer 演示文稿。我想减小给定块内代码的字体大小,以便一切都更合适。请看下面的例子:
生成chunk的代码是:
```{python}
# Import packages
import numpy as np
```
```{python}
#| echo: true
w = np.array([0.7, 0.3])
Sigma = np.array([[0.09, 0.1], [0.1, 0.25]])
var_rp = w.T @ Sigma @ w
print("Variance of our example portfolio {:.4f}".format(var_rp))
print("Standard Deviation of our example portfolio {:.2f}".format(np.sqrt(var_rp)))
```
有没有办法更改此块的字体大小,以便所有代码行都适合 pdf 中的一行?提前致谢!
指定一个
monofont
并使用monofontoptions
缩小字体。
---
title: "Small code font"
format: beamer
jupyter: python3
pdf-engine: lualatex
monofont: 'Source Code Pro'
monofontoptions:
- Scale=0.55
---
## Portfolio
Let's do this computation in python.....
```{python}
# Import packages
import numpy as np
```
```{python}
#| echo: true
w = np.array([0.7, 0.3])
Sigma = np.array([[0.09, 0.1], [0.1, 0.25]])
var_rp = w.T @ Sigma @ w
print("Variance of our example portfolio {:.4f}".format(var_rp))
print("Standard Deviation of our example portfolio {:.2f}".format(np.sqrt(var_rp)))
```