Skip to content

How do I convert a Latex document containing Tikz pictures to HTML? #10590

Answered by jgm
minoush82 asked this question in Q&A
Discussion options

You must be logged in to vote

Here's what I do in a book I'm working on. I use a Lua filter tex2image.lua:

local system = require 'pandoc.system'

local doc_template = [[
\documentclass{standalone}
\usepackage{bookgraphics} % Local package with my own macro definitions used in tikz diagrams
\begin{document}
%s
\end{document}
]]

local function tex2image(src, filetype, outfile)
    local f = io.open('tex-temp.tex', 'w')
    f:write(doc_template:format(src))
    f:close()
    local _, _, status = os.execute('lualatex -pdflua -auxdir=textmp -interaction=nonstopmode -halt-on-error -shell-escape tex-temp.tex')
    if status ~= 0 then
      os.exit(1)
    end
    if filetype == 'pdf' then
        os.rename('tex-temp.pdf', o…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@jgm
Comment options

jgm Jan 31, 2025
Maintainer

Answer selected by minoush82
Comment options

You must be logged in to vote
3 replies
@iandol
Comment options

@jgm
Comment options

jgm Feb 2, 2025
Maintainer

@minoush82
Comment options

Comment options

You must be logged in to vote
1 reply
@minoush82
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants