Importing from LaTeX...
Hello to all,
This is my first message to the list, so it may be duplicated or not adequate. Sorry in advance!
I am really enjoying Inkscape, specially in conjunction with TeX for scientific documentation. However, I miss the possibility of importing TeX material (e.g. complex labels and maths).
After some tests, I think that a transparent way to implement the above feature could be through the following script:
0. Open a text box to input TeX commands (e.g. text) 1. Run copy header.tex + text + footer.tex > clip.tex 2. Run pdfelatex clip.tex 3. Run pstoedit -dt -f svg clip.pdf clip.svg 4. File-Import: clip.svg 5. Run delete clip.*
where header.tex could be something like:
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \begin{document} \thispagestyle{empty}
and footer.tex:
\end{document}
I have tested this path manually under MSWindows using pstoedit 3.42 without problems. I know the SVG backend of pstoedit is not freeware, but as long as text is converted to curves by -dt, the output does not seem distorted (e.g. fontname distortion).
Does Inkscape supply any scripting to perform all the above tasks in order to integrate them as a simple menu option?
Thanks for your answers.
Best regards,
Paco
This is a short reply but I am pressed for time. I was working with this for a bit and found a nice simple compromise. All I did was include my TeX commands in text boxes and then exported to eps. Then I used the psfrag package to handle the latex for me. You cant just put the commands in a text box, it must be encapsulated by \TeX{ command } I think. it is all documented in the psfrag package. Hope this points you in the right way.
Justace
On Monday 17 October 2005 09:34 am, Francesc Serra Graells wrote:
Hello to all,
This is my first message to the list, so it may be duplicated or not adequate. Sorry in advance!
I am really enjoying Inkscape, specially in conjunction with TeX for scientific documentation. However, I miss the possibility of importing TeX material (e.g. complex labels and maths).
After some tests, I think that a transparent way to implement the above feature could be through the following script:
- Open a text box to input TeX commands (e.g. text)
- Run copy header.tex + text + footer.tex > clip.tex
- Run pdfelatex clip.tex
- Run pstoedit -dt -f svg clip.pdf clip.svg
- File-Import: clip.svg
- Run delete clip.*
where header.tex could be something like:
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \begin{document} \thispagestyle{empty}
and footer.tex:
\end{document}
I have tested this path manually under MSWindows using pstoedit 3.42 without problems. I know the SVG backend of pstoedit is not freeware, but as long as text is converted to curves by -dt, the output does not seem distorted (e.g. fontname distortion).
Does Inkscape supply any scripting to perform all the above tasks in order to integrate them as a simple menu option?
Thanks for your answers.
Best regards,
Paco
Hi Justace,
Thanks for that point.
However, and as you can imagine, seeing and playing interactively with the TeX object inside Inkscape is much more interesting than a simple post-processing of the postscript file. This feature is specially useful when the size and placement of the TeX object inside the SVG graphic is difficult.
Any idea of how to capture user text, execute a system script and some Inkscape functions by a simple menu option?
Thanks again
Paco
Justace Clutter wrote:
This is a short reply but I am pressed for time. I was working with this for a bit and found a nice simple compromise. All I did was include my TeX commands in text boxes and then exported to eps. Then I used the psfrag package to handle the latex for me. You cant just put the commands in a text box, it must be encapsulated by \TeX{ command } I think. it is all documented in the psfrag package. Hope this points you in the right way.
Justace
On Monday 17 October 2005 09:34 am, Francesc Serra Graells wrote:
Hello to all,
This is my first message to the list, so it may be duplicated or not adequate. Sorry in advance!
I am really enjoying Inkscape, specially in conjunction with TeX for scientific documentation. However, I miss the possibility of importing TeX material (e.g. complex labels and maths).
After some tests, I think that a transparent way to implement the above feature could be through the following script:
- Open a text box to input TeX commands (e.g. text)
- Run copy header.tex + text + footer.tex > clip.tex
- Run pdfelatex clip.tex
- Run pstoedit -dt -f svg clip.pdf clip.svg
- File-Import: clip.svg
- Run delete clip.*
where header.tex could be something like:
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \begin{document} \thispagestyle{empty}
and footer.tex:
\end{document}
I have tested this path manually under MSWindows using pstoedit 3.42 without problems. I know the SVG backend of pstoedit is not freeware, but as long as text is converted to curves by -dt, the output does not seem distorted (e.g. fontname distortion).
Does Inkscape supply any scripting to perform all the above tasks in order to integrate them as a simple menu option?
Thanks for your answers.
Best regards,
Paco
On Monday 17 October 2005 09:34 am, Francesc Serra Graells wrote:
....
After some tests, I think that a transparent way to implement the above feature could be through the following script:
- Open a text box to input TeX commands (e.g. text)
- Run copy header.tex + text + footer.tex > clip.tex
- Run pdfelatex clip.tex
- Run pstoedit -dt -f svg clip.pdf clip.svg
- File-Import: clip.svg
- Run delete clip.*
where header.tex could be something like:
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \begin{document} \thispagestyle{empty}
and footer.tex:
\end{document}
I have tested this path manually under MSWindows using pstoedit 3.42 without problems. I know the SVG backend of pstoedit is not freeware, but as long as text is converted to curves by -dt, the output does not seem distorted (e.g. fontname distortion).
Does Inkscape supply any scripting to perform all the above tasks in order to integrate them as a simple menu option?
Thanks for your answers.
Best regards,
Paco
Hi myself,
The best way to implement it is through the scripting extensions of Inkscape! For that purpose, I have created the latex2svg.inx file in the extensions directory, containing:
<inkscape-extension> <name>LaTeX to SVG</name> <id>org.inkscape.input.tex</id> <dependency type="executable" location="extensions">latex2svg.pl</dependency> <param name="header" type="string" gui-text=" LaTeX preamble: ">""latex2svg-header.tex""</param> <param name="source" type="string" gui-text=" LaTeX source: ">""$\displaystyle \frac{\pi}{\pi}=1$""</param> <param name="basename" type="string" gui-text=" Temp Basename: ">""latex2svg-clip""</param> <effect> <object-type>all</object-type> </effect> <script> <command reldir="extensions" interpreter="perl">latex2svg.pl</command> </script> </inkscape-extension>
and also the Perl file latex2svg.pl in the same directory to implement the initial script. Unfortunately, I still have a problem (maybe out of topic) when passing the three parameters to Perl! In order to parse them, I use the following code inside latex2svg.pl:
use Getopt::Long;
GetOptions("header" => $LaTeXHeader, "source" => $LaTeXSource, "basename" => $TempBaseName);
However, after executing 'Effects->LaTeX to SVG' from the Inkscape menu and accepting the correct fill-form window, the following message is returned from Perl:
Option header does not take an argument Option source does not take an argument Option basename does not take an argument
Then, changing the above Perl code by:
die("$ARGV[0] $ARGV[1] $ARGV[2] $ARGV[3] \n");
the answer is:
--header="latex2svg-header.tex" --source="$\displaystyle \frac{\pi}{\pi}=1$" --basename="latex2svg-clip"
which seems correct! Any idea??
Thanks in advance,
Paco
Francesc Serra Graells wrote:
On Monday 17 October 2005 09:34 am, Francesc Serra Graells wrote:
....
After some tests, I think that a transparent way to implement the above feature could be through the following script:
- Open a text box to input TeX commands (e.g. text)
- Run copy header.tex + text + footer.tex > clip.tex
- Run pdfelatex clip.tex
- Run pstoedit -dt -f svg clip.pdf clip.svg
- File-Import: clip.svg
- Run delete clip.*
where header.tex could be something like:
\documentclass{article} \usepackage[latin1]{inputenc} \usepackage[english]{babel} \usepackage[T1]{fontenc} \begin{document} \thispagestyle{empty}
and footer.tex:
\end{document}
I have tested this path manually under MSWindows using pstoedit 3.42 without problems. I know the SVG backend of pstoedit is not freeware, but as long as text is converted to curves by -dt, the output does not seem distorted (e.g. fontname distortion).
Does Inkscape supply any scripting to perform all the above tasks in order to integrate them as a simple menu option?
Thanks for your answers.
Best regards,
Paco
Hi myself (again),
#$%! it was just a Perl error. Finally, here are the files to be located in the Inkscape\share\extensions directory:
latex2svg.inx : Inkscape extension interface latex2svg.pl : Perl script
Also, a simple LaTeX header example is supplied (latex2svg.tex)...
This extension effectively creates the latex2svg-clip.svg file in the selected temp directory with all the compiled LaTeX material.
The question is, how can I execute in the *.inx file an automatic File->Import action for such a file???
Thanks in advance!
Paco
participants (2)
-
Francesc Serra Graells
-
Justace Clutter