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

Christopher W Ryan cryan at binghamton.edu
Tue Jan 31 23:33:18 CET 2017

I'm resurrecting a thread from back in October (month 10--two digits--this

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 system date., like this:

<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()
@

Each time I run the report, the name of the saved pdf file changes, to
match the system date. I want to include the
most current graph in my pdf output.

William Adams kindly provided this excellent solution:

\documentclass{article}

\usepackage{datenumber}

\begin{document}

NaloxoneUseEMS-timeseriesplot-\thedateyear-\thedatemonth-\thedateday

\end{document}

Which worked very well for a while.  But now that it is January (month 1,
or 01, and there is the crux of the problem) it no longer does.  Here is
part of the latex error message that provides a clue:

ERROR: LaTeX Error: File ERROR: LaTeX Error: File ERROR: LaTeX Error:

So it appears that the Latex package datenumber is searching for the
graphics file called

NaloxoneUseEMS-timeseriesplot-2017-1-31.pdf (which of course does not exist)

whereas my R code is creating the graphics file called

NaloxoneUseEMS-timeseriesplot-2017-01-31.pdf (which was successfully
created and is sitting in the proper directory.)

Can I make datenumber use 2 digits for \thedatemonth?

Thanks.

--Chris Ryan

On Fri, Oct 14, 2016 at 3:15 PM, Christopher W Ryan <cryan at binghamton.edu>
wrote:

> William--
>
> Fantastic! Thanks!
>
> --Chris
>
> On Fri, Oct 14, 2016 at 2:43 PM, William Adams <will.adams at frycomm.com>
> wrote:
> > \documentclass{article}
> >
> > \usepackage{datenumber}
> >
> > \begin{document}
> >
> > NaloxoneUseEMS-timeseriesplot-\thedateyear-\thedatemonth-\thedateday
> >
> > \end{document}
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20170131/2de51948/attachment.html>
`