I am looking for a reliable way to convert a pdf from a latex file to SVG for display in a browser
\documentclass{article}
\pagenumbering{gobble}
\usepackage{blkarray}
\usepackage{xcolor}
\definecolor{darkred}{rgb}{0.55, 0.0, 0.0}
% -----------------------------------------------------------------------------------------------
\begin{document}
\begin{blockarray}{rrrrrrrrrr}
\begin{block}{rrrr(cccc|c)!{\quad}l}
& & & & 1 & 2 & 2 & 1 & 8 & the pivot is in row 2, col 2\
& & & & 0 & {\colorbox{yellow}{\color{darkred}{$\boxed{1}$}}} & -1 & 0 & 0 & It will be multiplied by\
& & & & 0 & {\colorbox{yellow}{\color{darkred}{-2}}} & 1 & -2 & -5 & entries in column 1 of $E$ \
& & & & 0 & {\colorbox{yellow}{\color{darkred}{\ 1}}} & -1 & 1 & 2 & \
\end{block}
\end{blockarray}
\end{document}
- I had used
\documentclass{standalone}which did not work I ended up with removing the pagenumber and using the following ugly shellscript
!/bin/sh
latexmk -pdflatex $1.tex && \
latexmk -pdflatex -c $1.tex && \
pdf2svg $1.pdf /tmp/temp_$1.svg && \
inkscape -D --without-gui --file=/tmp/temp_$1.svg --export-plain-svg $1.svg
Questions
- Is there a simpler way to create the svg so that the image is cropped to the actual extent? (the -D option for inkscape)
- Is there a simpler way to create the pdf so that it only displays that image, rather than the whole page?
- The parentheses enclosing the matrix get messed up with most of my attempts. What would I need to do to ensure that parens will be correctly rendered
- can whatever solution use xelatex rather than pdflatex?
standalone? I’ve sometimes wrapped the contents in display math or a minipage to get that to work. – Davislor Aug 26 '20 at 04:00dvisvgminstead. It ships with TeXLive and MiKTeX. – AlexG Aug 26 '20 at 05:55! Undefined control sequence. <recently read> \boxed– AlexG Aug 26 '20 at 06:23\usepackage{nicematrix}in the original preamble – ea42_gh Aug 26 '20 at 12:07dvisvgm --font-format=woff2 --zoom=-1 --exact your-example.dvi– AlexG Aug 26 '20 at 14:49amsmathpackage is missing... then you might have got theUndefined control sequenceerror, as I had. – LEo Jan 27 '21 at 21:56pdf2svgobsolete? IMHO,dvioutput is much more obsolete, so usage ofdvisgmmakes no sense. – wipet Feb 22 '22 at 07:26dvisvgmis just a name. It also converts PDF. – AlexG Feb 22 '22 at 07:58-Pflag can be used to make dvisvgm output PDF. That having said, unfortunately none ofdvisvgm,inkscape,pdf2svgpreserves the hyperlinks in my testing. StackOverflow question on that: Inkscape pdf to svg export - retain hyperlinks - Stack Overflow – user202729 Dec 29 '23 at 14:44