[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Texmacs-dev] new feature: copy as image, export selection as image
texmacs . 5 . pjoyez
[Texmacs-dev] new feature: copy as image, export selection as image
Fri, 06 Jul 2012 14:24:06 +0200
Thunderbird 126.96.36.199 (X11/20100411)
Those who were in Albufeira probably remember the hack I showed that
allowed to copy-paste from TeXmacs to Inkscape with the possibility to
re-edit the original content in TeXmacs. With this feature, one can use
Texmacs as a convenient wysiwyg equation editor for Inskcape. You can
also copy-paste other image formats (png, jpg ...) to other applications
(e.g. LibreOffice), but with no re-edition capability so far.
What I showed in Albufeira was really an ugly hack on the texmacs side,
partly implemented with a python script. With some input from Joris I
could rewrite this in scheme, and Joris recently committed it.
Please be kind enough to consider this stuff as work in progress.
Presently I would say it is fairly usable in Linux (on which I develop)
and Joris reports it works already partly on MacOS. I'd greatly
appreciate help from those of you guys working on MacOS (Max, Miguel,
any free time?) and Windows (Denis?) to make it fully working on those
See the attached file for installation instructions, usage, and present
<item>TeXmacs needs external converters to produce images. Make sure you
have the required converters installed and in your path
<item>Ghostscript's utilities <verbatim|ps2pdf> and <verbatim|ps2epsi>
<item><verbatim|pdf2svg> (available in most Linux distributions, and
MacPorts provide it for MacOS)
<item>If you want to use the feature with Inkscape, you'll need Inkscape
version \<gtr\>= 0.47 (current stable is 0.48.3). In MacOS Joris reports
that the dmg from Inkscape website lacks a python library necessary to
re-edit equations, but MacPorts' Inkscape is fine. Be sure to install
Inkscape before the next step.
<item>Get and compile the latest TeXmacs from svn. After install, run
<verbatim|texmacs --setup> once, in order to install the ``TeXmacs
equation'' plugin in your user Inkscape directory, that will allow
You can export the texmacs selection as a graphics file using
"File/Export/Selection as graphics..." (The image format that gets exported
is determined from the file extension you specify).
You can copy texmacs selection to the clipboard using "edit/copy to image".
The graphics format that gets pasted on the clipboard is defined in
"Preferences/Converters/Selection-\<gtr\>Image on clipboard".
SVG graphics created this way can be opened or pasted in Inkscape and
re-edited in texmacs provided the "texmacs equation" inkscape extension is
installed in the proper location (see Install).
Bitmaps formats images can be copy-pasted to many applications (Gimp,
<subsection|Modifying/Inserting a TeXmacs equation from within an Inkscape
Select an existing equation (or nothing to enter a new one) and chose the
menu item "Extensions/TeXmacs equation". This should bring up the equation
to be edited in a <em|new> TeXmacs instance. During edition Inkscape is in
a modal dialogue: you cannot do anything before terminating the edition of
this equation. This is an Inkscape limitation; not my fault. In Texmacs
however, you can open another document where you already have the equation
you want and paste it to the document opened from Inkscape. When finished,
everything between the top of the document and the line saying "When
finished ... " will be converted to svg and transferred to Inkscape. You
will have to authorize the script on a case by case basis or permanently in
``Preferences/Security/Accept all scripts''. Be cautious however if you
already had a Texmacs instance running with an important document : the new
instance clears the cached files of the first instance and that may crash
it (see bug ).\
In Inkscape these equations are grouped objects. If you ungroup the
equation you loose the ability to re-edit it (the texmacs code is inside
that group, and is lost with the ungrouping). You can however enter the
group by double-clicking it and then mofify the content of the group (add
elements, colorize items, move them around.... double click outside the
equation on a blank part to leave the group when you're done). Of course if
you re-edit an equation changed this way in Inkscape, such changes will be
lost. Some global transforms made on the group such as rotation, zoom,
effects,... will survive editing though, but not a global color change (you
will need to re apply it). If you want colored equations, it is preferable
to apply colors inside TeXmacs.
<subsection|Compatibility with Inscape plugin Textext>
People using Textext equations in Inkscape (re-editable Latex equations
plugin shipped with Inkscape) can edit the equations you produce with
texmacs, provided they use the style file containing the texmacs macros and
necessary includes. Conversely, you can work on their files, re-opening
their textext equations with texmacs. Hence, you can keep collaborating
with people who do not (yet) want to switch to texmacs equations.
<subsection|Present limitations and Known Issues>
Presently the copy-paste mechanism is not working on MacOS. The machinery
used is based on Qt and should be cross-platform, but there seems to be a
twist. I would appreciate if someone could debug this since I do not have a
No testing has been done so far on the windows platform. Pathes and calls
to external converters surely need adjustment. If someone wants to peek
into this I can provide the pdf2svg.exe converter that is needed.
If some characters appear pixelated in Inkscape, you are maybe missing some
extra font (download the extra font package from texmacs website), or
texmacs is not configured for "type 1 font" printing preference. Note
however that some characters (e.g. strechable arrows) are inherently
bitmaps already in TeXmacs<with|color|orange|>.
Presently you cannot copy-paste between two TeXmacs instances (say, when
you are re-editing an equation from Inkscape). A work-around is to perform
an intermediate paste and copy again in a plain text editor.
If the selection in texmacs contains an embedded postscript image, there is
a high probability that the svg will be invalid (the postscript raw data is
not properly escaped for #00 characters). Then Inkscape simply pretends
there is no data on the clipboard.
If the selection contains a macro call with the macro definition outside of
the selection, it won't be rendered (\<less\>error\| compound xx\<gtr\>)...
<with|par-left|<quote|1.5fn>|Modifying/Inserting a TeXmacs equation
from within an Inkscape drawing
<with|par-left|<quote|1.5fn>|Compatibility with Inscape plugin Textext
- [Texmacs-dev] new feature: copy as image, export selection as image,
texmacs . 5 . pjoyez <=