1

Background

A wiki page, written in Markdown, is run through pandoc to produce a .tex file for ConTeXT. The wiki page makes references to images that are located in a path relative to the page itself. For example, the wiki page is:

 http://wiki.server.com/xwiki/bin/view/Clients/Projects/CR1234567

When the wiki page is exported, the references to the images resemble:

<img src="/xwiki/bin/download/Clients/Projects/CR123457/WebHome/image.svg"/>

Then pandoc transforms the .html file to .tex as:

{\externalfigure[/xwiki/bin/download/Clients/Projects/CR1234567/WebHome/image.svg]}

The images can be exported into that particular directory relative to a parent "images" directory. The hierarchy resembles:

./
./images/
./images/xwiki/bin/download/Clients/Projects/CR1234567/WebHome/

Where ./ is the directory wherein ConTeXt runs.

Problem

It appears as though externalfigures cannot use relative paths.

Code

The figures are setup as follows:

\setupexternalfigures[
  order={svg, pdf, png, jpg},
  factor=fit,
  maxwidth=\textwidth,
  maxheight=\pageheight,
  directory={images},
]

The following directory option was also tried without success:

  directory={images, images/xwiki/bin/download/Clients/Projects/CR123457/WebHome},

Invocation

None of the following ConTeXt invocations worked (--trackers=graphics.conversion revealed no obvious problems):

context --path=styles main.tex
context --path=styles,images main.tex
context --path=styles,images\xwiki\bin\download\Clients\Projects\CR1234567\WebHome main.tex
context --path=styles,images/xwiki/bin/download/Clients/Projects/CR1234567/WebHome main.tex

Question

Can ConTeXt include an external figure that is referenced using a relative path? If so, how?

Environment

Note that pandoc generates externalfigures rather than useexternalfigures.

  • ConTeXt MKIV 2018.01.04 17:37
2

Unfortunately, your question is posed in such a way that it is impossible for me to reproduce your exact setup and error.

It appears as though externalfigures cannot use relative paths.

Not true. This works for me in TL 2017 and standalone on Ubuntu 16.04.

\starttext
\externalfigure[../../usr/local/texlive/2017/texmf-dist/tex/latex/mwe/example-image-a.png]
\stoptext
\setupexternalfigures[directory={../../usr/local/texlive/2017/texmf-dist/tex/latex/mwe/}]
\starttext
\externalfigure[example-image-a.png]
\stoptext

Something else must be wrong.

Note that the externalfigure starts with an absolute path, /xwiki. This will have to change. You can either try writing a pandoc filter, or use a program such as sed to change the path to a relative directory, such as:

sed -i "s/\/xwiki/.\/images/g" %TEX%
  • Ah! Now I get your problem. It seems that this is a problem of the reader because the pandoc ConTeXt writer does not touch the image path in any way. I guess the same issue would appear with other writers. – Henri Menke Jan 8 '18 at 23:50
  • You could try with one of their official Windows builds and if it still crashes, file an issue. – Henri Menke Jan 8 '18 at 23:58
  • 1
    My changes are not merged yet but if their builds also crash it is definitely not my fault ;) – Henri Menke Jan 9 '18 at 0:07

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.