GithubHelp home page GithubHelp logo

jghuangcn / svg2tex Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oni/svg2tex

0.0 0.0 0.0 252 KB

A python script that exports text from *.svg files to LaTeX picture environment

Python 100.00%

svg2tex's Introduction

Svg2tex

Svg2tex is a python script that extracts all text from a *.svg file to a LaTeX picture environment. This way the picture's text is processed directly by LaTeX and can be included into the document.

Download it now: tar or zip file.

Usage

Svg2tex can be used as an inkscape extension or as a standalone script. The final result is the same.

Inkscape extension

Installing svg2tex is very easy. Under Linux you only need to copy svg2tex.py and output.inx under /home/<your username>/.inkscape/extensions. Under Windows just copy the same files under C:\<inkscape installation directory>\share\extensions\ . At this point it's necessary to restart inkscape. Under the save menu there should be a new option: LaTeX (text only) picture environment (*.tex).

Command-line

Svg2tex can also be called from command-line. Here it is the syntax:

python svg2tex.py <options> <svg-input-file> <tex-output-file>

The <tex-output-file> is optional and, if it's not given, the LaTeX output is printed in standard output. The <options> can be any of the following:

  • -i <filename> (or --include <filename>) - set the background image of the picture environment to <filename>,
  • -t <filename> (or --textless <filename>) - make a copy of the original *.svg file without text and save it as <filename>.

Even from command-line, svg2tex can be paired with inkscape. The next simple shell script, for example, converts all *.svg files in the directory into ready-to-use LaTeX + *.pdf pictures:

#!/bin/sh

for file in *.svg
do
  echo "Processing ${file}..."
  fn=${file%.svg}
  python svg2tex.py -i "${fn}" -t "${fn}.tl.svg" "${file}" "${fn}.tex"
  inkscape --export-pdf="${fn}.pdf" "${fn}.tl.svg"

  rm "${fn}.tl.svg"
done

More info

The documentation file also has a step-by-step example on how to use svg2tex with inkscape.

svg2tex's People

Contributors

oni avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.