Giter Club home page Giter Club logo

writetex's Introduction

Due to incompatible change of Inkscape extension API, this extension has to split into two versions. For Inkscape version lower than 1.0, users should use the files in 0.9.x folder, the other users should use files in 1.0.x folder.

You may also want to check WriteTeX2.

Logo

An Inkscape extension: Latex/Tex editor for Inkscape, inspired by textext.

This extension uses Inkscape build-in extension system, does not require TK or PyGtk as textext. Live preview feature is supported. You can obtain original TeX source from View Original TeX tab.

Installation

Just drop writetex.py and writetex.inx to Inkscape extension folder, which is normally at $inkscapeFolder$/share/extensions.

Make sure one LaTeX command and one PDFtoSVG converter are in your path.

Notes on PDFTOSVG

PDFTOSVG must be installed and added to your search path, otherwise you will get error like "IOError: Error reading file somesvg.svg". One supported PDFTOSVG is pdf2svg, which can be downloaded following locations:

  • For Windows user, pdf2svg can be downloaded from here or here.
  • For Mac user, pdf2svg can be installed by homebrew, or download from here.

More info

Can be found in the website.

writetex's People

Contributors

alphamodel avatar gitter-badger avatar wanglongqi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

writetex's Issues

error

'''''
Latex error: check your latex file and preamble.
Traceback (most recent call last):
File "writetex.py", line 347, in
e.affect()
File "inkex.py", line 283, in affect
self.effect()
File "writetex.py", line 158, in effect
print(open(log_file).read(),file=sys.stderr)
IOError: [Errno 2] No such file or directory: 'c:\users\haohao~1\appdata\local\temp\writetex-ugpec8\writetex.log'
'''''''''

I have tried a lot of times on win10.

Does not work with inkscape

'''text
writetex.py:33: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-f", "--formula",
writetex.py:37: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-p", "--preamble",
writetex.py:41: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("--read-as-line",
writetex.py:45: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-s", "--scale",
writetex.py:49: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-i", "--inputfile",
writetex.py:53: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-c", "--pdftosvg",
writetex.py:57: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("--action", action="store",
writetex.py:60: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-r", "--rescale",
writetex.py:64: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-l", "--latexcmd",
writetex.py:68: DeprecationWarning: Effect.OptionParser or optparse has been deprecated and replaced with argparser.You must change self.OptionParser.add_option to self.arg_parser.add_argument; the arguments are similar.
self.OptionParser.add_option("-t", "--tosvg",
writetex.py:356: DeprecationWarning: Effect.affect is now Effect.run(). The output argument has changed.
e.affect()
writetex.py:290: DeprecationWarning: inkex.etree was removed, use "from lxml import etree"
doc = inkex.etree.parse(svg_file)
writetex.py:281: DeprecationWarning: inkex.etree was removed, use "from lxml import etree"
svgout = inkex.etree.Element(inkex.addNS('g', 'WriteTexNS'))
Traceback (most recent call last):
File "writetex.py", line 356, in
e.affect()
File "/usr/share/inkscape/extensions/inkex/deprecated.py", line 180, in affect
return self.run(args=args)
File "/usr/share/inkscape/extensions/inkex/base.py", line 123, in run
self.save_raw(self.effect())
File "writetex.py", line 172, in effect
self.merge_pdf2svg_svg(svg_file)
File "writetex.py", line 294, in merge_pdf2svg_svg
WriteTexNS] = self.text.encode('string-escape')
LookupError: unknown encoding: string-escape

'''

Latex error : writetex.log not found

Hey, I try to use Writetext in Inkscape on Ubuntu. I installed it, Inkscape recognizes the extension, but I get the following error:
/bin/sh: 1: pdflatex: not found Latex error: check your latex file and preamble. CMD executed: pdflatex "-output-directory=/tmp/writetex-Nf8gwq" -interaction=nonstopmode -halt-on-error "/tmp/writetex-Nf8gwq/writetex.tex" > "/tmp/writetex-Nf8gwq/writetex.out" Traceback (most recent call last): File "writetex.py", line 360, in <module> e.affect() File "/home/rusandris/snap/inkscape/5874/extensions/inkex.py", line 289, in affect self.effect() File "writetex.py", line 166, in effect print(open(log_file).read(), file=sys.stderr) IOError: [Errno 2] No such file or directory: '/tmp/writetex-Nf8gwq/writetex.log'
I added pdflatex to my PATH variable, still get this error. Can you anyone help me with
issue
this?

WriteText won't output Figure

Hi!
I have Inkscape 0.92.3, running over Win10 and I'm trying to write Latex equations with WriteTeX 1.6.2.
I installed the extension, following the instructions on the guide.

My problem:
I write an equation (with the proper preamble) in the WriteTeX form and select to write output to Figure. However no Figure is generated, just a very fast pop up (error?)message.

image

Traceback after WriteTeX installation on Ubuntu

Recently I heard about this extension for inkscape. So I tried to install, following the steps mentioned in the official page.
My operating system is ubuntu 18.04. I copied both files on /usr/share/inkscape/extensions/
On LateX Source I put $\frac{x^2}{z}$. But when I click on 'Apply' a window with the below message is showed...
Traceback (most recent call last): File "writetex.py", line 376, in <module> e.affect() File "/usr/share/inkscape/extensions/inkex.py", line 283, in affect self.effect() File "writetex.py", line 180, in effect self.merge_pdf2svg_svg(svg_file) File "writetex.py", line 306, in merge_pdf2svg_svg WriteTexNS] = self.text.encode('string-escape') LookupError: unknown encoding: string-escape
Also I tried changing all the options on PDF to SVG converter and Latex Command used to Compile to pdflatex, but the traceback persist. Finally, I ran which pdf2svg on the terminal and the output was /usr/bin/pdf2svg.

Won't render equations

I'm getting the following error in a "simple" installation on Ubuntu.

The equation is just a test, $\alpha$. ANy idea what's failing and how to fix it?
untitled 2

ImportError: No module named inkex

Traceback (most recent call last):
File "writetex.py", line 15, in
import inkex
ImportError: No module named inkex

This appears after I try to run it.

IndexError on use

Hello,

I get an IndexError when WriteTex runs.
screenshot from 2017-11-02 16-53-48

I am running Inkscape 0.92.2

Hello....I follow the instructions and I receive the following error message.

Hello:

I follow the instructions to install WriteTeX....and I try to put the equation as Capture01 in inkscape 0.92.2.

I have installed MikTeX 2.9 (full) that have xelatex and pdf2svg included and the directories are in PATH variable.

capture01

When I follow to Apply.....I receive this....Capture02
capture02

But at the end the pdf was created....as LaTeX notify me. I check in the temp files but the file doesn't exist.

capture03

Thank you for your support.

Cesar

`PDFCROP` does not output the cropped pdf.

Under MAC OSX and Linux conditions, the package with pdfcrop works well. However, I found the pdfcrop command does not produce any output under a standard Windows installation. I failed in finding what is happening here. The pdfcrop command was executed, but the cropped pdf does not produced.

I will look into this when I have time. Anyone has any thought on this issue?

Windows: unknown encoding: string-escape

Hi,

First of all, thank you for the extension.

I followed the instructions and tested the extension with the simple $\frac{1}{2}$ command but got this error:

Traceback (most recent call last):
  File "writetex.py", line 347, in <module>
    e.affect()
  File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 283, in affect
    self.effect()
  File "writetex.py", line 164, in effect
    self.merge_pdf2svg_svg(svg_file)
  File "writetex.py", line 286, in merge_pdf2svg_svg
    WriteTexNS] = self.text.encode('string-escape')
LookupError: unknown encoding: string-escape

Any idea?

Thank you!

[Suggestion] handle_path function puts newpath before old os.environ["PATH"] is better.

I use archlinux with texlive installed in /usr/local/ folder, which is not in typical os PATH (something like /usr/bin/....). After I add /usr/local/texlive/2022/bin/x86_64-linux to new path, the handle_path function will append new path to os PATH. However, archlinux have some broken tex binary in /usr/bin (I don't know why and when they were installed), so inkscape always use these broken tex binary instead of /usr/local/texlive/.
In my opinion, users who config new path are likely to use this new path first instead of old os path. Therefore, I think handle_path function puts newpath before old os.environ["PATH"] is better.

I change line 373 to

            os.environ['PATH'] = newpath + os.path.pathsep + os.environ['PATH'] 

Error Reading File

Hello,

First of all thank you for your work in continuing the legacy of TexText.

After installation, the extension starts fine. However, when I try to 'apply' or 'Live Preview' any of my TeX string, I have been receiving the following error:

Traceback (most recent call last):

Traceback (most recent call last):
  File "writetex.py", line 358, in <module>
    e.affect()
  File "inkex.py", line 283, in affect
    self.effect()
  File "writetex.py", line 175, in effect
    self.merge_pdf2svg_svg(svg_file)
  File "writetex.py", line 293, in merge_pdf2svg_svg
    doc = inkex.etree.parse(svg_file)
  File "src/lxml/lxml.etree.pyx", line 3442, in lxml.etree.parse (src/lxml/lxml.etree.c:81716)
  File "src/lxml/parser.pxi", line 1811, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:118635)
  File "src/lxml/parser.pxi", line 1837, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:118982)
  File "src/lxml/parser.pxi", line 1741, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:117894)
  File "src/lxml/parser.pxi", line 1138, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:112440)
  File "src/lxml/parser.pxi", line 595, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:105896)
  File "src/lxml/parser.pxi", line 706, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:107604)
  File "src/lxml/parser.pxi", line 633, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:106415)
IOError: Error reading file '$my user folder/\appdata\local\temp\writetex-yi3j67\writetex.svg': failed to load external entity "file:/$my user folder/appdata/local/temp/writetex-yi3j67/writetex.svg"

Currently running Inkscape 0.92.2, XeLatex, and both PDF2SVG and PStoEDIT.

Error seems to occur regardless of what is put in for the latex source.

Also tried commenting out

WriteTeX/writetex.py

Lines 181 to 192 in b1f9dee

os.remove(tex_file)
os.remove(log_file)
os.remove(out_file)
if os.path.exists(err_file):
os.remove(err_file)
if os.path.exists(aux_file):
os.remove(aux_file)
if os.path.exists(svg_file):
os.remove(svg_file)
if os.path.exists(pdf_file):
os.remove(pdf_file)
os.rmdir(tmp_dir)

Per a closed issue and had no luck there either.

Let me know if you need any other information.

Error reading temp file

When I try to use the extension, I get this error:

IOError: Error reading file 'c:\users\victor\appdata\local\temp\writetex-upcfhd\writetex.svg': failed to load external entity "file:/c:/users/victor/appdata/local/temp/writetex-upcfhd/writetex.svg"

I think I have everything installed properly. Any idea what is happening?

Problem using the fourier package

Many thanks for writing this package, it is really useful.
I have the following issue:
When using the fourier package in the preamble (in order to use the Utopia font) something weird happens: the equals sign ("=") does not appear in the equations.
Accoding to https://tex.stackexchange.com/questions/196025/sign-not-properly-displayed
this may be due to a conflict between the fourier package and the lmodern package. However, I do not know how to implement the solution showed there.
2017-11-22_1212

FileNotFoundError

Hello,

I receive this error

Latex error: check your latex file and preamble.
 CMD executed: xelatex "-output-directory=C:\Users\ANDREW~1\AppData\Local\Temp\writetex-bvhwybqn" -interaction=nonstopmode -halt-on-error "C:\Users\ANDREW~1\AppData\Local\Temp\writetex-bvhwybqn\writetex.tex" > "C:\Users\ANDREW~1\AppData\Local\Temp\writetex-bvhwybqn\writetex.out"
Traceback (most recent call last):
  File "writetex.py", line 377, in <module>
    e.run()
  File "C:\Program Files\Inkscape\share\inkscape\extensions\inkex\base.py", line 140, in run
    self.save_raw(self.effect())
  File "writetex.py", line 175, in effect
    print(open(log_file).read(), file=sys.stderr)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\ANDREW~1\\AppData\\Local\\Temp\\writetex-bvhwybqn\\writetex.log'

when I execute WriteTex on Inkscape (Windows OS). How can the log file be created programmatically to resolve the error?

WriteTeX and Inkscape 1.2

The extension does not seem to work with Inkscape 1.2. Any thoughts on how I can debug / help you debug the situation?

Shawn Way

Path environment not set correctly when running from within a Mac OSX .app bundle.

First off I'll note that this may not necessarily be an issue with WriteTeX, but it can be addressed in your code base. I was not able to find a similar report related to inkscape in their issue tracker.

Behavior: WriteTeX is not able to find latex interpreter or .svg converter when run from inkscape launched from an .app bundle on OS X. Apparently this is because .app bundles do not respect the environment variables set in various locations (.profile, /etc/profiles, and so forth).

Expected behavior: WriteTeX should rely on the user set PATH environment variable to search for latex interpreter and svg converter.

Other info: The issue only occurs when launching inkscape from an .app bundle. Calling the inscape executable inside the bundle via terminal correctly passes the PATH environment variable.

Here are the PATHS returned by calling 'echo $PATH' from within writetex.py:
inkscape from terminal: /Applications/Inkscape.app/Contents/MacOS:/Applications/Inkscape.app/Contents/MacOS/../Resources/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
inkscape launched as .app:
/Applications/Inkscape.app/Contents/MacOS:/Applications/Inkscape.app/Contents/MacOS/../Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin

entering the full path to the latex interpreter in the modal window can fix the latex interpreter issue, but there is no way to provide the full path to the svg converter.

There area bunch of ways I've been able to club this into submission such as: symlinks located in the .app bundle to point to the latex interpreter and svg converters, getting and altering the path within writetex.py using os.environ and using the env= flag in subprocess.call(), etc. None of these are particularly convenient from a user standpoint.

As mentioned up front, it is possible that there is a clean way to fix this within inkscape, but I expect that the developers here are much more familiar with the extension codebase than I am.

Inkscape 1.0 binary from inkscape.org
OS X 15.4
writeTex 1.0.x

update needed for Inkscape version 1.0

Hello,
Thank you for providing this extension for Inkscape users!

This is just to let you know that most 3rd party Inkscape extensions, like this one, probably will not work with the upcoming new Inkscape version, the long-awaited version 1.0.

Here is the info you need to update this extension, so that it will work with 1.0 and future versions.
https://wiki.inkscape.org/wiki/index.php?title=Updating_your_Extension_for_1.0

If you have further questions, you can contact Inkscape developers via mailing lists, forum, or the chatroom.

If you have already updated it, please disregard this message.

All best,
brynn

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.