Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to make use of "svg in tex" technology.

Here's a tex:

\documentclass{article}
\usepackage{color}
\usepackage{graphicx}

\newcommand{\executeiffilenewer}[3]{%
    \ifnum\pdfstrcmp{\pdffilemoddate{#1}}%
        {\pdffilemoddate{#2}}>0{\immediate\write18{#3}}
    \fi}

\newcommand{\includesvg}[1]{%
    \executeiffilenewer{#1.svg}{#1.pdf}%
        {inkscape -z -D --file=#1.svg --export-pdf=#1.pdf --export-latex}%
    \input{#1.pdf_tex}}

\begin{document}
\begin{figure}
    \centering
    %\def\svgwidth{\columnwidth}
    \includesvg{svgfig}
    \caption{My SVG Image}
\end{figure}
\end{document}

One can take any svg image.

Then:

pdflatex -shell-escape tex-file

works, but

xelatex -shell-escape tex-file

and

xelatex -shell-escape -8bit tex-file

both give error:

! Undefined control sequence.
\executeiffilenewer #1#2#3->\ifnum \pdfstrcmp 
                                              {\pdffilemoddate {#1}}{\pdffil...
l.19     \includesvg{svgfig}

Edit:

Currently I prepare pdfs from svg before compiling then doc, so I do have "svgs in xetex". I even automated the thing in bash, so I'm pretty happy. Nevertheless, all problems should be solved, and all issues cleared -- so if someone aware of XeTeX internals thinks something is wrong -- it sould be reported and fixed.

share|improve this question
    
XeTeX’s equivalent primitive is \strcmp not \pdfstrcmp, so it is a bug in the relevant package. –  Khaled Hosny Nov 30 '12 at 14:37
    
@KhaledHosny: Now it gives: \executeiffilenewer ...m \strcmp {\pdffilemoddate. –  Adobe Nov 30 '12 at 19:28
    
XeTeX does not have an equivalent primitive, I’m afraid. Unless you have hundreds of SVG images, may be you can just remove the \executeiffilenewer command and do the conversion on each run. –  Khaled Hosny Nov 30 '12 at 19:42

1 Answer 1

up vote 4 down vote accepted

There are two issues; the XeTeX string comparing primitive is called \strcmp not \pdfstrcmp, so that is easy to fix (a more portable way is to use \pdf@strcmp from pdftexcmds package, which handle engine differences).

The other problem is the lack of a XeTeX implementation of \pdffilemoddate. I opened a XeTeX ticket, for when I have time to look into it, but patches are welcomed of course.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.