[texhax] include a pdf graphics file whose name includes a varying date

Mike Marchywka marchywka at hotmail.com
Fri Oct 14 20:59:09 CEST 2016


I am fully unfamiliar with some of the choices you may have, indeed I was asking earlier for some
names of scripting facilities, but I wrote a build script for my latex source code largely to
work with bibliographic entries that I found while composing. 

For a recurring report however where generation time is not a big issue personally I would probably
write a bash script- you can get cygwin for example on Windows- and add
comments to your latex source or come up with a syntax for things that get modified each time. This
allows you to integrate R and anything else you may need with a very familiar command
language. 

Here is a simple example of a latex code generator for checking a bib adapted from the
below URL.This same approach works for html , c++ etc easily. You define the file names
in the bash script, use them to generate R script and latex and then you can keep track
of everything without a lot of language specific stuff.  It is easily adaptable to many settings,
I have used R on servers to respond to queries for example, and the code gives you nice
references for later use. 

#http://tex.stackexchange.com/questions/173621/how-to-validate-check-a-biblatex-bib-file
testbibtex()
{
cat - << ----
\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{plain}
\bibliography{mybib}
\end{document}
----
}


testbibtex | sed -e "s/mybib/$fn/" > $fntest
XLBM="pdflatex -file-line-error -halt-on-error -interaction batchmode"



________________________________________
From: texhax <texhax-bounces at tug.org> on behalf of Christopher W Ryan <cryan at binghamton.edu>
Sent: Friday, October 14, 2016 2:19 PM
To: texhax at tug.org
Subject: [texhax] include a pdf graphics file whose name includes a varying date

I am using R and Sweave and MikTeX on Windows 7.  I use this workflow
to generate a recurring report quarterly. Same report, just new data.

The R code generates a graph, saving it as a pdf file, the filename
including the date.  Each time I run the report, I want to include the
most current graph. How would I do that?

Example code (just excerpts, does not actually compile, but I think it
will convey my intent):

<<timeseriesplot, results=hide, echo=FALSE>>=
# make the major graph
pdf(file=paste("NaloxoneUseEMS-timeseriesplot-", Sys.Date(), ".pdf",
sep=""), height=8, width=12)
## bunch of R code in here to create a graph
dev.off()
@


The later in the file, I have:

\begin{figure}\centering
  \includegraphics{NaloxoneUseEMS-timeseriesplot-2016-08-04}
\end{figure}
 ^^^^^^^^^^^^^

     here is the problem

     How do I make this

     part of the figure filename

     increment to match SysDate()

     from R in the code chunk above?


I understand I could just include the code-generating chunk inside a
Sweave environment with fig=TRUE, but I have some reasons for
preferring to save the graph as a pdf file and use it later.

Thanks.

--Chris Ryan
_______________________________________________
TeX FAQ: http://www.tex.ac.uk/faq
Mailing list archives: http://tug.org/pipermail/texhax/
More links: http://tug.org/begin.html

Automated subscription management: http://tug.org/mailman/listinfo/texhax
Human mailing list managers: postmaster at tug.org



More information about the texhax mailing list