The array
package gives the capability to replicate a declaration before every cell in a specifed column column. So if you have a column for a price, you can use a format like: {ll>{\$}r}
to put a dollar sign before every price.
Usually you want long dates in the text of a document (e.g. 5th August, 2021). Of course exceptionally you would usually want short dates in a table column. But this is broken:
\Begin{tabular}{l>{\DTMsetdatestyle{default}\DTMsetup{datesep=/}}rl}
col 1 && \DTMusedate{mydate} && col 3\\
\end{tabular}
The middle column still prints the long form of dates. It obviously clusterfucks the table to put the long-ass \DTMsetdatestyle{default}\DTMsetup{datesep=/}
in every middle cell.
The only workaround I can think of is to nest the whole table inside braces ({}
), and nest the date config with it:
{\DTMsetdatestyle{default}\DTMsetup{datesep=/}
\begin{tabular}{lrl}
col 1 && \DTMusedate{mydate} && col 3\\
\end{tabular}}
I’m calling it a bug because there is no good reason make code inside >{}
happen in a separate scope as the cell that preceeds.
I make table with dates in the columns often, and reuse them yearly with new dates. I haven't had the exact problem you discuss, but I bet my lame workaround would help: I edit all my table content in a spreadsheet as a csv file with ampersand as the delimiter. Then I open the csv file with a text editor and copy/paste it into LaTeX.
Not that this solves the problem you found. It just makes editing and reusing tables much easier for me.
That would work if dates are not reused. But if you have a block of
\DTMsavedate
variables in the preamble and then refer to those dates throughout the doc by the variable name you assign, the spreadsheet would be more trouble than it’s worth because you would have to copy-paste all the dates into the spreadsheet, choose the new format, copy them back, and risk the update anomaly in the event that you revise a date in the preamble. Could be useful for some situations though. But I guess I would still rather replicate\DTMsetdatestyle{default}\DTMsetup{datesep=/}
in every cell that needs it.