Everything is Connected

tex2svg

Word count: 228Reading time: 1 min
2021/05/31 Share

When I want to save a bunch of tex equations/symbols as svg files I find there is no efficient software to fulfill this goal. But I find the interesting pipeline which is implemented on a Linux system. The following is what I did on my CentOS7 server.

Install Latex

Login in as root. Then install texlive using the following two commands

1
2
yum install texlive-latex
yum install texmaker

Check your pdflatex version using

1
pdflatex --version

Install pdfcrop

pdfcrop is written by perl. First install perl on CentOS

1
yum install perl

Check the perl version using

1
perl -v

Then download or clone the pdfcrop repository

1
git clone https://github.com/ho-tex/pdfcrop.git

cd to the directory where you can see the perl file. Run with a test pdf using

1
perl pdfcrop.pl test.pdf

The output is named as

1
test-crop.pdf

Install poppler

The original pipeline uses pdf2svg which requires poppler and cairo of high version. Installing dependencies on CentOS7 is a terrible struggle. The simplest way is to use pdftocairo which is contained in poppler-utils.

1
yum install poppler-utils

Then run with a test pdf

1
pdftocairo test.pdf output.svg -svg

Pack the pipeline

Write a bash script to pack all steps together.

1
2
3
4
5
6
7
#!/bin/bash

vim test.tex
pdflatex test.tex
perl pdfcrop.pl test.pdf
pdftocairo test-crop.pdf output.svg -svg
rm test.* test-crop.pdf
CATALOG
  1. 1. Install Latex
  2. 2. Install pdfcrop
  3. 3. Install poppler
  4. 4. Pack the pipeline