惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Security Latest
Security Latest
P
Privacy International News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
S
Secure Thoughts
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
V
Visual Studio Blog
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
V
V2EX
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tenable Blog
T
Threat Research - Cisco Blogs
T
Troy Hunt's Blog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
L
Lohrmann on Cybersecurity
F
Full Disclosure
H
Help Net Security
博客园 - Franky
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
A
Arctic Wolf
O
OpenAI News
S
Securelist

Homepage on Yihui Xie | 谢益辉

Bye, Stack Overflow - Yihui Xie | 谢益辉 Converting testthat Tests to testit - Yihui Xie | 谢益辉 Reflections on AI-assisted Programming - Yihui Xie | 谢益辉 R.I.P., Tomas Kalibera - Yihui Xie | 谢益辉 An Introduction to xfun - Yihui Xie | 谢益辉 tinyimg: An R Package for Compressing Images - Yihui Xie | 谢益辉 The Surprising Slowness of `textConnection()` in R - Yihui Xie | 谢益辉 A CDN-backed CTAN Mirror: `tlnet.yihui.org` - Yihui Xie | 谢益辉 Announcing TinyTeX Binaries for arm64 and musl-based Linux - Yihui Xie | 谢益辉 TinyTeX on macOS: No More Messing with `/usr/local/bin` - Yihui Xie | 谢益辉 R.I.P., John Fox - Yihui Xie | 谢益辉 R.I.P., Fritz Leisch - Yihui Xie | 谢益辉 Bye, Hex Stickers - Yihui Xie | 谢益辉 Navigating CRAN's Reverse Dependency Check Logs - Yihui Xie | 谢益辉 Viewing Nested Lists with `xfun::tabset()` - Yihui Xie | 谢益辉
Preliminary Support for Typst in knitr - Yihui Xie | 谢益辉
Yihui Xie · 2026-04-27 · via Homepage on Yihui Xie | 谢益辉

A few weeks ago I added preliminary support for Typst to knitr. The way it works is simple: if your file has the extension .Rtyp, knitr will recognize it as a Typst document, knit it, and produce a .typ output file. The chunk syntax follows the same Markdown-style fenced code block convention: ```{r} to start a chunk and ``` to end it, with inline R expressions written as `r expr`. A minimal example (hello.Rtyp):

#set page(paper: "a4")
#set text(font: "New Computer Modern", size: 11pt)

= Hello, Typst!

```{r}
x = rnorm(10)
summary(x)
```

The mean is `r round(mean(x), 3)`.

Install the latest development version of knitr and restart R:

install.packages('knitr', repos = 'https://yihui.r-universe.dev')

Then you run either:

knitr::knit("hello.Rtyp")      # produces hello.typ
knitr::knit2pdf("hello.Rtyp")  # produces hello.pdf

That’s about it. I called this “preliminary” support because I have not done extensive testing, and there are probably rough edges. If give this a try and run into any problems, please feel free to leave comments below or file issues to the knitr repo on Github.

On Typst itself

Typst is quite impressive and its rendering speed seems to be unbeatable. I understand why so many people in the R community are excited about it. However, for knitr / rmarkdown / Quarto users, I think the bottleneck in dynamic documents (.Rtyp, .Rmd, .qmd) is almost never the typesetting step—it’s the computation in code chunks. The speed argument for Typst is compelling for pure writing workflows; for data analysis documents, I’m skeptical it matters much in practice.

And then there is the larger question of whether you need PDF at all.

In HTML I Still Trust

I have believed for a long time that HTML is the better target for almost everything, including what people typically reach for PDF to accomplish: typesetting for reading, sharing, and archiving. You get hyperlinks, search, accessibility, reflowable text, responsive layout, and zero installation requirements—free, in a browser that everyone already has.

If you really need paginated output that looks like a printed document, it is more achievable from HTML than you’d imagine. I have a small script pages.js that typesets a continuous HTML page into individual pages—you can press P (or Ctrl/Cmd + P) on any page at yihui.org/litedown/ to see the effect. The result is not perfect, but it is good enough for many use cases, and you get to keep all the benefits of HTML along the way. BTW, I handcrafted pages.js from scratch in 2024 without AI assistance, and I have to confess that while the code is relatively short, it was the most challenging piece of JavaScript I had ever written (again, the recursion almost killed me). I guess today’s AI can do a much better job than me.

The accessibility angle is one I keep hearing more about, and rightly so. HTML is dramatically better than PDF on this front—screen readers, keyboard navigation, zoom, high-contrast mode, all of it works because browsers have been doing this for decades. LaTeX has finally made some progress here, too (e.g., the tagpdf package), which is great, but still there are so many things that I doubt would ever become possible in LaTeX.

Bye, LaTeX (and Typst, although we never met)

Typst support in knitr is there if you want it, and I think Typst is a great tool. I wouldn’t use it myself but I’m happy to serve those who do use it. I gave up MS Office around 2009 after becoming a LaTeX fan for a few years. In 2024, I decided that I wouldn’t use LaTeX anymore (when I need PDF, I just use pages.js to print HTML). I believe HTML still has a lot of potential that I need to explore further, and I really look forward to it.

Again, this doesn’t mean I’m abandoning my support for LaTeX. Actually I still work quite hard in this regard, as you can tell from some of my previous posts this year.

Donate

As a freelancer (currently working as a contractor) and a dad of three kids, I truly appreciate your donation to support my writing and open-source software development! Your contribution helps me cope with financial uncertainty better, so I can spend more time on producing high-quality content and software. You can make a donation through methods below.

  • Venmo: @yihui_xie, or Zelle: [email protected]

  • Paypal

    • If you have a Paypal account, you can follow the link https://paypal.me/YihuiXie or find me on Paypal via my email [email protected]. Please choose the payment type as “Family and Friends” (instead of “Goods and Services”) to avoid extra fees.

    • If you don’t have Paypal, you may donate through this link via your debit or credit card. Paypal will charge a fee on my side.

  • Other ways:

    WeChat Pay (微信支付:谢益辉) Alipay (支付宝:谢益辉)
    WeChat Pay QR code Alipay QR code

When sending money, please be sure to add a note “gift” or “donation” if possible, so it won’t be treated as my taxable income but a genuine gift. Needless to say, donation is completely voluntary and I appreciate any amount you can give.

Please feel free to email me if you prefer a different way to give. Thank you very much!

I’ll give back a significant portion of the donations to the open-source community and charities. For the record, I received about $30,000 in total (before tax) in 2024-25, and gave back about $15,000 (after tax).