uwdata / living-papers

Authoring tools for scholarly communication. Create interactive web pages or formal research papers from markdown source.
BSD 3-Clause "New" or "Revised" License
128 stars 10 forks source link

LaTeX can't access images with relative paths #34

Closed joshuahhh closed 1 year ago

joshuahhh commented 2 years ago

If you include a (non-svg) image with a relative path, generated LaTeX won't be able to find it because the LaTeX lives in .temp/latex and the paths are relative to the root.

joshuahhh commented 2 years ago

This works as a hack for me:

async function rewriteImagePaths(ast) {
  visitNodes(ast, node => {
    if (node.name === 'image') {
      setValueProperty(node, 'src', '../../' + getPropertyValue(node, 'src'));
    }
  });
  return ast;
}

It conflicts with the convert plugin, but I'm avoiding that for my paper.

jheer commented 1 year ago

Fixed by inserting a \graphicspath{...} directive as dynamic preamble content.