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

Here's a tex:



        {inkscape -z -D --file=#1.svg --export-pdf=#1.pdf --export-latex}%

    \caption{My SVG Image}

One can take any svg image.


pdflatex -shell-escape tex-file

works, but

xelatex -shell-escape tex-file


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}


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.

Edit 2:

The script I'm using is too opinioned. Here's basic simple script which does the job:

# to get description use the -h flag

# exit after a single error:
set -e

# ==========
# preambula:


TeX=`find . -maxdepth 1 -mindepth 1 -type f -name '*.tex' | sort | head -1`

cat << EO

Script to build xelatex documents. It expects document following a particular rules.



cat << EO | column -s\& -t

  -t, --tex & TeX file (default to first TeX in the dir, currently it is: $TeX)
  -i, --index & also build index: xelatex-(biber-xelatex)-makeindex-xelatex-xelatex
  -e, --extra & perform and extra XeLaTeX run
  -h, --help & show this output
  -v, --version & show version information


ARGS=$(getopt -s bash --options $SHORTOPTS --longoptions $LONGOPTS --name $PROGNAME -- "$@")

eval set -- "$ARGS"

while true; do
    case $1 in

            TeX=$2; shift;;

            usage; exit 0;;
            echo "$PROGVERSION"; exit 0;;
            shift; break;;
            shift; break;;

# ===========
## variables:

TexBaseName=`basename ${TeX%.tex}`

# =====================
## updating svg images:

find . -type f -name '*.svg' | while read svgFile; do
    svgBasename=`basename $svgFile`
    svgDir=`dirname $svgFile`
    if [ ! -e $pdfFile -o $svgFile -nt $pdfFile ]; then
        echo -e "${PROGNAME}: $svgFile is newer!"
        inkscape -z -D --file=$svgFile --export-pdf=$pdfFile --export-latex

# ==========
## building:

# initial build
xelatex -shell-escape "${TeX}"

# bibliography: run biber + xelatex if there's a bcf file.
# And bcf file is there if you have loaded biblatex.
Bib=`find . -type f -name '*.bib'`
if [ -n "$Bib" ]; then
    biber `ls *.bcf` || echo $?
    # setting links:
    xelatex -shell-escape "${TeX}"

# setting links:
xelatex -shell-escape "${TeX}"

# extra build?
if $Extra; then
    xelatex -shell-escape "${TeX}"

# ===========
## reporting:

echo -e "${PROGNAME}: Done."

I called it bk_XeLaTeXs_simple.bash. In order to build a doc just run this one in the dir of your master tex file. This script assumes the first tex file in the dir to be a master tex file, but you can also set it with the -t/--tex option.

The script looks for a svg files, and compares each of them with a corresponding pdf file: if svg is newer (or pdf does not exists), then script uses inkscape to re-generate pdf file. So to load an svg file called x-y-sigma.svg one would write:

  \caption{Test svg image.\label{fig:x-y-sigma}}

This script also calls biber on *bcf files if you have loaded biblatex in you sources.

Finally it has -e/--extra option for an extran xelatex build.

Here's a zip of the folder with all the files needed for a complete MWE with svg and bibliography.

  • 1
    XeTeX’s equivalent primitive is \strcmp not \pdfstrcmp, so it is a bug in the relevant package. Nov 30, 2012 at 14:37
  • @KhaledHosny: Now it gives: \executeiffilenewer ...m \strcmp {\pdffilemoddate.
    – Adobe
    Nov 30, 2012 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. Nov 30, 2012 at 19:42
  • Can you please copy paste your bash script @Adobe , i can offer some bounty on that :) ?
    – reyman64
    Feb 5, 2015 at 7:19
  • @reyman64 I'll do it in an hour, no need for a bounty.
    – Adobe
    Feb 5, 2015 at 8:15

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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