Ok, I hacked together some code that accomplished the date portion of this. (Hugely helped by this blog.) A similar edit would work to change the title and/or author. I'm not sure how robust this is but it did the trick.
Basically, you will need to edit the tplx files in your /nbconvert/templates/latex
directory. Specifically, I edited base.tplx
. Where it had
((* block date *))((* endblock date *))
I changed this to
((* block date *))
((*- if nb.metadata["latex_metadata"]: -*))
((*- if nb.metadata["latex_metadata"]["date"]: -*))
\date{((( nb.metadata["latex_metadata"]["date"] )))}
((*- endif *))
((*- endif *))
((* endblock date *))
Then in the notebook metadata, I added
"latex_metadata": {
"date": "CUSTOM DATE HERE"
},
The ,
at the very end depends on if it is the last line in your metadata structure. If no latex_metadata tag exists, it leaves the date empty and latex substitutes the current date.
The only issue I haven't been able to fix is that when I run Download as -> PDF via LaTeX, it doesn't always rerun the LaTeX generator (sometimes it just gives me the LAST pdf it created, not a new one.) I can't figure out why it runs it sometimes and doesn't othertimes.
*Edit*
My exact metadata section in a jupyter notebook now looks like this (I'm using the date field to show a due date for my students):
{
"anaconda-cloud": {},
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.7.9",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"latex_metadata": {
"date": "Due April 7 at 11:59pm"
}
}