Combine datetime2 and csvsimple
How can I make the following code compile:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtime{b}}
end{document}
Note that it does compile if I replace b
by 00:00:01
csvsimple datetime2
add a comment |
How can I make the following code compile:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtime{b}}
end{document}
Note that it does compile if I replace b
by 00:00:01
csvsimple datetime2
add a comment |
How can I make the following code compile:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtime{b}}
end{document}
Note that it does compile if I replace b
by 00:00:01
csvsimple datetime2
How can I make the following code compile:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtime{b}}
end{document}
Note that it does compile if I replace b
by 00:00:01
csvsimple datetime2
csvsimple datetime2
asked Mar 18 at 21:04
GerhardGerhard
432
432
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The problem is that DTMtime
expects its argument to already be expanded. You can see the problem if you say:
deftest{00:00:00}
DTMtime{test}
this already throws an error. You need to expand first test
and then run DTMtime
on it. One way to do this is by saying
edeftemp{noexpandDTMtime{test}}temp
The command edef
defines a new macro by recursively expanding the body of the macro. The command noexpand
stops DTMtime
from being expanded, so that temp
gets defined as DTMtime{00:00:00}
which then works as expected.
I like to define this inside of a macro, say called eval
:
defeval#1{edeftemp{#1}temp}
eval{noexpandDTMtime{test}}
Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx
which edef
's the argument of a macro before calling it, so then exp_args:NxDTMtime{test}
will expand test
first and then run DTMtime
on it. You can define a wrapper macro for DTMtime
that always expands its argument first. Here's sample code for that:
documentclass{standalone}
usepackage{expl3}
usepackage{datetime2}
ExplSyntaxOn
cs_new:NpnDTMtimex { exp_args:NxDTMtime }
ExplSyntaxOff
begin{document}
deftest{00:00:00}
DTMtimex{test}
end{document}
Here's complete code:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
defeval#1{edeftemp{#1}temp}
defDTMtimex#1{eval{noexpandDTMtime{#1}}}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtimex{b}}
end{document}
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480157%2fcombine-datetime2-and-csvsimple%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem is that DTMtime
expects its argument to already be expanded. You can see the problem if you say:
deftest{00:00:00}
DTMtime{test}
this already throws an error. You need to expand first test
and then run DTMtime
on it. One way to do this is by saying
edeftemp{noexpandDTMtime{test}}temp
The command edef
defines a new macro by recursively expanding the body of the macro. The command noexpand
stops DTMtime
from being expanded, so that temp
gets defined as DTMtime{00:00:00}
which then works as expected.
I like to define this inside of a macro, say called eval
:
defeval#1{edeftemp{#1}temp}
eval{noexpandDTMtime{test}}
Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx
which edef
's the argument of a macro before calling it, so then exp_args:NxDTMtime{test}
will expand test
first and then run DTMtime
on it. You can define a wrapper macro for DTMtime
that always expands its argument first. Here's sample code for that:
documentclass{standalone}
usepackage{expl3}
usepackage{datetime2}
ExplSyntaxOn
cs_new:NpnDTMtimex { exp_args:NxDTMtime }
ExplSyntaxOff
begin{document}
deftest{00:00:00}
DTMtimex{test}
end{document}
Here's complete code:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
defeval#1{edeftemp{#1}temp}
defDTMtimex#1{eval{noexpandDTMtime{#1}}}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtimex{b}}
end{document}
add a comment |
The problem is that DTMtime
expects its argument to already be expanded. You can see the problem if you say:
deftest{00:00:00}
DTMtime{test}
this already throws an error. You need to expand first test
and then run DTMtime
on it. One way to do this is by saying
edeftemp{noexpandDTMtime{test}}temp
The command edef
defines a new macro by recursively expanding the body of the macro. The command noexpand
stops DTMtime
from being expanded, so that temp
gets defined as DTMtime{00:00:00}
which then works as expected.
I like to define this inside of a macro, say called eval
:
defeval#1{edeftemp{#1}temp}
eval{noexpandDTMtime{test}}
Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx
which edef
's the argument of a macro before calling it, so then exp_args:NxDTMtime{test}
will expand test
first and then run DTMtime
on it. You can define a wrapper macro for DTMtime
that always expands its argument first. Here's sample code for that:
documentclass{standalone}
usepackage{expl3}
usepackage{datetime2}
ExplSyntaxOn
cs_new:NpnDTMtimex { exp_args:NxDTMtime }
ExplSyntaxOff
begin{document}
deftest{00:00:00}
DTMtimex{test}
end{document}
Here's complete code:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
defeval#1{edeftemp{#1}temp}
defDTMtimex#1{eval{noexpandDTMtime{#1}}}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtimex{b}}
end{document}
add a comment |
The problem is that DTMtime
expects its argument to already be expanded. You can see the problem if you say:
deftest{00:00:00}
DTMtime{test}
this already throws an error. You need to expand first test
and then run DTMtime
on it. One way to do this is by saying
edeftemp{noexpandDTMtime{test}}temp
The command edef
defines a new macro by recursively expanding the body of the macro. The command noexpand
stops DTMtime
from being expanded, so that temp
gets defined as DTMtime{00:00:00}
which then works as expected.
I like to define this inside of a macro, say called eval
:
defeval#1{edeftemp{#1}temp}
eval{noexpandDTMtime{test}}
Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx
which edef
's the argument of a macro before calling it, so then exp_args:NxDTMtime{test}
will expand test
first and then run DTMtime
on it. You can define a wrapper macro for DTMtime
that always expands its argument first. Here's sample code for that:
documentclass{standalone}
usepackage{expl3}
usepackage{datetime2}
ExplSyntaxOn
cs_new:NpnDTMtimex { exp_args:NxDTMtime }
ExplSyntaxOff
begin{document}
deftest{00:00:00}
DTMtimex{test}
end{document}
Here's complete code:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
defeval#1{edeftemp{#1}temp}
defDTMtimex#1{eval{noexpandDTMtime{#1}}}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtimex{b}}
end{document}
The problem is that DTMtime
expects its argument to already be expanded. You can see the problem if you say:
deftest{00:00:00}
DTMtime{test}
this already throws an error. You need to expand first test
and then run DTMtime
on it. One way to do this is by saying
edeftemp{noexpandDTMtime{test}}temp
The command edef
defines a new macro by recursively expanding the body of the macro. The command noexpand
stops DTMtime
from being expanded, so that temp
gets defined as DTMtime{00:00:00}
which then works as expected.
I like to define this inside of a macro, say called eval
:
defeval#1{edeftemp{#1}temp}
eval{noexpandDTMtime{test}}
Another option is to do this using Latex3. Latex3 defines the macro exp_args:Nx
which edef
's the argument of a macro before calling it, so then exp_args:NxDTMtime{test}
will expand test
first and then run DTMtime
on it. You can define a wrapper macro for DTMtime
that always expands its argument first. Here's sample code for that:
documentclass{standalone}
usepackage{expl3}
usepackage{datetime2}
ExplSyntaxOn
cs_new:NpnDTMtimex { exp_args:NxDTMtime }
ExplSyntaxOff
begin{document}
deftest{00:00:00}
DTMtimex{test}
end{document}
Here's complete code:
documentclass{standalone}
usepackage{csvsimple}
usepackage{datetime2}
usepackage{filecontents}
begin{filecontents*}{test.csv}
a,b
2019,00:00:00
2019,00:00:01
2020,00:00:02
2018,00:00:03
2018,00:00:04
end{filecontents*}
defeval#1{edeftemp{#1}temp}
defDTMtimex#1{eval{noexpandDTMtime{#1}}}
begin{document}
csvreader[head to column names,tabular=llllll]{test.csv}{}
{a&DTMtimex{b}}
end{document}
edited Mar 18 at 21:19
answered Mar 18 at 21:12
Hood ChathamHood Chatham
4,3791428
4,3791428
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480157%2fcombine-datetime2-and-csvsimple%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown