I'm trying to write a scientific article and the associated supplementary materials entirely in RStudio with rmarkdown.
It seems clear that book down is the way to go to cross-reference between files (https://stackoverflow.com/a/38884378/576684), but I also would like to be able to reference figures produced in one pdf in the other pdf.
Although my latex has got quite rusty with time, I imagine it could be achieved as follows:
- compile the article tex and SuppMat tex a first time using rmarkdown::render()
- compile these tex files from the command line in order to keep the corresponding .aux file with their references (missing references won't be resolved at this time)
- recompile the 2 tex files from the command line another time where all references should now be resolved
Is it a reasonable way to do it? am I overlooking something simpler? In any case, it requires:
- a different numbering of figures in each pdf file (covered by https://stackoverflow.com/a/51337664/576684)
- to prevent rmarkdown from trashing the .aux files (it seems that pandoc doesn't allow this, hence the need to create the aux file using standalone latex)
- to tell latex to use the additional .aux file if it is found (probably using
header-includes:
in the YAML header). how can I achieve that?
Thank you very much for your help!