Trash aux files for LaTeX


I wish there was a button for “Trash Aux Files” when working with LaTeX (or RMarkdown that compiles to LaTeX) in RStudio. @JimmyLovesTea and I are collaborating on a JSS paper, using the rticles template, and keep doing something wrong that leaves us stuck with many auxiliary files. As is often the case, the auxiliary files then get used by LaTeX to try to compile, even when you’ve fixed the error in the source. In TeXShop, I would just click “Trash Aux files” and they would all disappear, but in RStudio I have to click the checkbox next to each one individually, then trash them. Can we have a convenience button?


@AmeliaMN I’m not sure if this is what you’re looking for, but if you head to:

Tools > Global Options > Sweave

There’s a checkbox where you can “Clean auxiliary output after compile” in RStudio 1.1.423.


Using the JSS template from rticles, the auxiliary files are trashed after a successful compilation. It seems like the issue we’re having is when the compilation is unsuccessful, the auxiliary files remain (Which I imagine is a feature, not a bug); however, after fixing the “error” leading to an unsuccessful compilation, the document won’t re-compile unless we trash the auxiliary files.


I know this is a bit of a cop-out, but you could roll your own:

clear_cache <- function() {
  vapply(dir(pattern = "\\.(aux)|(bbl)|(bcf)|(blg)|(lof)|(out)|(run\\.xml)|(toc)$"),

Then Ctrl+2, clear_cache() (or an abbreviation), Ctrl+Shift+K.