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

Mike Marchywka marchywka at hotmail.com
Wed Feb 1 16:44:18 CET 2017


Well, there is also the issue of testing and reliability for automated things you set up.
This padding issue is something easy to miss for, well, several months :)
With things like generated images or ads, you may actually need a human to look at it.
In this case, the code that geneates the file name to request should have a good
way to report a failure. Certainly if latex fails just mailing the output to someone is great
and easy to diagnose but it may be easier to create some kind of exception
for the dependent action- in this case the existence of an external file of unknwon status.

With a code generator each user can have a consistent error mechanism built
into the generated code for example.
So, sure you can use the more obscure features if you know them but the code
generator does let you centralize logic better. 

Sometimes you need "pure tex" to send to say a publisher but often it is just a way
to make a pdf file for human consumption. The code generator mechanism makes
this easy to integrate into a server for ad hoc document generation. 

fwiw. Again curious what others are doing as I have not done much tex lately.


________________________________________
From: William Adams <will.adams at frycomm.com>
Sent: Wednesday, February 1, 2017 10:15 AM
To: Mike Marchywka
Cc: Christopher W Ryan; TeXHaX List
Subject: Re: [texhax] include a pdf graphics file whose name includes a varying date

If there're robust date classes / packagees, it shouldn't matter which / where and they all ought to synch up.

Agree, if one can have a single point of control, that's potentially better, but it's often easier to use a native tool in a given operation than reaching outside of it, grabbing some external value and then continuing.

William


On Wed, Feb 1, 2017 at 10:10 AM, Mike Marchywka <marchywka at hotmail.com<mailto:marchywka at hotmail.com>> wrote:


I'm still curious about the tex scripting options but would just point out that when apps have to
talk to each other, it may be better to generate things like file names in one location and then share
them. Which leads me to my next comment that instead of learning all the app specific text processing
tools, you have sed and awk etc available for every application. You can write bash scripts to
generate shared variables and then have R or tex find them or even write bash scripts
that generate R and tex code. So far I've had good luck with this approach and used
variants for a java based server that needed to make use of R for some ( slow  ) queries.

You have no idea when you may have to add time zones or even go to millisecond times
for example with dates. Changing this once is a lot easier than hunting down all the clients.

Thoughts?

________________________________________
From: texhax <texhax-bounces at tug.org<mailto:texhax-bounces at tug.org>> on behalf of William Adams <will.adams at frycomm.com<mailto:will.adams at frycomm.com>>
Sent: Wednesday, February 1, 2017 8:19 AM
To: Christopher W Ryan
Cc: TeXHaX List
Subject: Re: [texhax] include a pdf graphics file whose name includes a varying date

While David's solution (of course) works, I'm pretty sure that if you consult the documentation for the package datenumber there will be an option to enable padding with a leading zero (though it's odd to me that apparently this is turned one for days? Or have you never had to do a report during the first nine days of a month?)

William

On Tue, Jan 31, 2017 at 5:39 PM, David Carlisle <d.p.carlisle at gmail.com<mailto:d.p.carlisle at gmail.com><mailto:d.p.carlisle at gmail.com<mailto:d.p.carlisle at gmail.com>>> wrote:
\ifnum\thedatemonth<10 0\fi\thedatemonth

David

On 31 January 2017 at 22:33, Christopher W Ryan <cryan at binghamton.edu<mailto:cryan at binghamton.edu><mailto:cryan at binghamton.edu<mailto:cryan at binghamton.edu>>> wrote:
> I'm resurrecting a thread from back in October (month 10--two digits--this
> is of consequence).  My challenge was 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: File
> `NaloxoneUseEMS-timeseriesplot-2017-1-31' not found.
>
>
> 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<mailto:cryan at binghamton.edu><mailto:cryan at binghamton.edu<mailto: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<mailto:will.adams at frycomm.com><mailto:will.adams at frycomm.com<mailto:will.adams at frycomm.com>>>
>> wrote:
>> > \documentclass{article}
>> >
>> > \usepackage{datenumber}
>> >
>> > \begin{document}
>> >
>> > NaloxoneUseEMS-timeseriesplot-\thedateyear-\thedatemonth-\thedateday
>> >
>> > \end{document}
>
>
>
> _______________________________________________
> 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<mailto:postmaster at tug.org><mailto:postmaster at tug.org<mailto:postmaster at tug.org>>





More information about the texhax mailing list