haghish / markdoc

A literate programming package for Stata which develops dynamic documents, slides, and help files in various formats
http://haghish.com/markdoc
87 stars 30 forks source link

Including an image with dynamic path #12

Closed louisdecharson closed 7 years ago

louisdecharson commented 7 years ago

Hi, I want to include image which has a dynamic path (the image is created in a loop) but the markdoc output stopped when I do so. My code looks like:

foreach var in $mylist {
   box `var'
   graph export ./figs/fig_`var'.eps, replace
   txt ![Boxplot of variable `var'](./figs/fig_`var'.eps)
}

The code is running fine although the .docx generated by Markdoc stopped after graph export in the first iteration. The log file .smcl looks fine, title and path to the file are correct : `var' is correctly replaced by the name of the var. Is it normal behaviour ? Is there any workaround ? Thanks a lot for your time. Louis

haghish commented 7 years ago

PostScript is naturally not supported! Please read the documentation carefully.

haghish commented 7 years ago

Alternatively, read the img command.

louisdecharson commented 7 years ago

I do not understand your answer. PostScript _is working_ . All the other images without a dynamic path are rendered perfectly. See the example below:

capture log close
qui log using test_markdoc, replace smcl
sysuse auto.dta
graph box price
graph export box_price.eps, replace
/***
![Box of price](box_price.eps)
***/
qui log c
markdoc test_markdoc, replace export(docx) install 

This code is producing the attached output:

screen shot 2016-09-28 at 23 12 19

The reason I prefer not using img command is that it's not working with Unix-console (I'm using Stata inside emacs). Doing it leads to the error translator Graph2png not found.

The problem is really with the dynamic path. Again, all the other .eps graphs are rendered perfectly.

haghish commented 7 years ago

Ok, PostScript can be rendered in LaTeX and Docx. But not if you create HTML for example. So I understand the problem better now. Yes, unfortunately, in Unix console you can't export PNG or if you run batch mode.

Still, there should be no problem with the dynamic path. I will need more information before I can help.

Also, I think this is a kind of question that should be discussed on statalist because others might have similar questions or ideas to solve it. Please post the question with detailed description there and provide the following:

I'll take it from there

louisdecharson commented 7 years ago

Thanks a lot for your answer. You're right, I'm going to use Statalist, here is the post.