Skip to content

Commit

Permalink
mutool for workflow and exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sun123zxy committed Oct 29, 2024
1 parent 2488d31 commit bb4535e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
tlmgr install dvisvgm
tlmgr path add
dvisvgm --help
- name: Install mutool
run: sudo apt-get install mutool

- name: Prepare for TikZ rendering
# To import libraries in advance for tikz image generation
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@

### 关于 TikZ / tikzcd

HTML / PDF / Beamer 格式现已支持 TikZ / tikzcd / [quiver](https://q.uiver.app/).如需在输出非 PDF / Beamer 格式下输出,请确保 XeLaTeX、dvisvgm 已在 PATH 中,且已安装需要使用的 LaTeX 宏包(目前 TikZ 中使用的宏包无法在渲染过程中自动安装).
HTML / PDF / Beamer 格式现已支持 TikZ / tikzcd / [quiver](https://q.uiver.app/).如需在输出非 PDF / Beamer 格式下输出,请确保 XeLaTeX、dvisvgm、mutool 已在 PATH 中,且已安装需要使用的 LaTeX 宏包(目前 TikZ 中使用的宏包无法在渲染过程中自动安装).

- 如使用 Quarto 自带的 TinyTeX:

- 先输出一次 PDF 自动补全大部分所需宏包
- 执行 `tlmgr install dvisvgm``tlmgr path add` 下载 dvisvgm 并添加至 PATH.
- Linux 执行 `sudo apt install mupdf-tools`

- 在 Beamer 中使用时,所在幻灯片须添加 `{.fragile}` 标记.

- 可能还需要安装 mutool 并添加至 PATH
- 关于 mutool 必要性的一些说明

> As of Ghostscript 10.01.0, this will no longer work due to the introduction of a new PDF interpreter. Therefore, an alternative conversion module based on mutool, a utility which is part of the MuPDF package, has been introduced. It’s automatically invoked if Ghostscript can’t be used and if a working mutool executable is present in a directory which is part of the system’s search path.
>
Expand Down
6 changes: 4 additions & 2 deletions _assets/tikz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ local function tikz2image(src, filetype)
system.with_working_directory(tmpdir, function()
local f = io.open('mytikz.tex', 'w')
if f == nil then
str = "failed to open extracted TeX file: tikz.tex"
str = "failed to open extracted TeX file"
error(str)
return nil
end
f:write(tikz_doc_template:format(src))
Expand All @@ -35,7 +36,8 @@ local function tikz2image(src, filetype)
os.execute('dvisvgm mytikz.pdf --pdf --zoom=1.5 --font-format=woff2 --no-styles')
local g = io.open('mytikz.svg', 'r')
if g == nil then
str = "failed to open converted SVG file: mytikz.svg"
str = "failed to open converted SVG file"
error(str)
return nil
end
str = g:read("a")
Expand Down

0 comments on commit bb4535e

Please sign in to comment.