Well, on this one, I might bring my record down to commercial software bug fix time lines...
> I have trouble using odfInsertPlot to insert plots outside fig=TRUE > chunks. > > My goal is to dump a bunch of (relatively uninteresting, but required) > graphs from within a loop, possibly interspeded with some tables. This > is not possible within a normal fig=TRUE chunk. > > odfInsertPlot() is able to insert a previously saved plot. When used in > a fig=TRUE, results=hide chunk, it produces just a blank frame (with a > caption if caption=odfFigureCaption() is used). > > Used in a fig=TRUE, results=xml chunk, it produces an error at file > rte-assembly (see end of post). However, when wrapped in a cat(), the > same code produces 1) the figure (without caption), then a blank frame > with the caption, or just the figure (without caption) if the caption=() > argument is absent. > > The same cat(odfInsertPlot()) construct can be used in a results=xml > chunk (no fig=TRUE) ; however, I found no way to insert the caption. > > Therefore : I can programmatically create graphs and insert them via > results=xml chunks, but I can't caption them. We had to do some interesting things to get figure captions working with odfWeave. You would think that the figure caption function just write out some xml and are done (like the insert plot code and the table caption code). Unfortunately, it doesn't. It writes the caption to a global variable (I know, I know) and other code actually writes the caption. We had good reason to do this, mostly related to the complexity associated with the context of the code chunk (e.g. was it inside a table, at paragraph, etc). I've been thinking about this one for a while since the current implementation doesn't allow you to pass the figure caption to other functions (it writes a global variable and returns NULL). I haven't come up with a good solution yet. <aside> I've not been as prompt with odfWeave changes in comparison to other packages (many of you have figured this out). This is mostly due to the necessary complexity of the code. In a lot of ways, I think that we let the feature set be too rich and should have put some constrains on the availability of code chunks (e.g. only in paragraphs). I want to add more features (like the one that you are requesting), but seemingly small changes end up being a considerable amount of work (and I don't time). I've been thinking about simplifying the code (or writing rtfWeave) to achieve the same goals without such a complex system. The ODF format is a double-edged sword. It allows you to do many more things than something like RTF, but makes it a lot more difficult to program for. Take tables as an example. The last time I looked at the RTF specification, this was a simple markup structure. In ODF, the table structure is somewhat simple, but the approach to formatting the table is complex and not necessarily well documented. For example, some table style elements go into styles.xml whereas others go into contest.xml (this might be implementation dependent) So, I could more easily expand the functionality of odfWeave by imposing some constraints about where the code chunks reside. The earlier versions of odfWeave did not even parse the xml; we got a lot done via regular expressions and gsub. However, we went to a xml parsing approach when we found out that the context of the code chunk matters. Feedback is welcome: do people actually use code chunks in places other than paragraphs? </aside> So, back to your question, the relevant code for captions is in odfWeave:::withCaptionXML (odfInsertPlot uses this to write the xml). You can try that and I might be able to look at it in the next few days. Thanks, Max ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.