Use datatool input to enable beamer frame
I want to use the value of a flag imported from a datatool database (stored in an external .csv file) to enable (or disable) a beamer frame.
The .csv file is of the form:
begin{filecontents*}{test.csv}
test enable
test1 ok
test2 ok
test3 ok
end{filecontents*}
Imported into a datatool database :
DTLloaddb{test}{test.csv}
My command:
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
I'm trying to use the frameIsEnabled
command to enable the frame fetching the database value:
begin{frame}<presentation: frameIsEnabled{DTLfetch{test}{test1}{enable}}>
But latex is not happy. I suppose there is something wrong related to the format of the fetched value DTLfetch{test}{test1}{enable}
.
If I display it (i.e. in a table or text) it returns zero (i.e. the comparison with the string "ok" returns false
).
Here's a minimal example to reproduce my problem.
Example 1, to verify the comparison of the "enable" flag with the string "ok":
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:1>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
Within this code, the frameIsEnabled
command will return 0
, while the desired output is 1
Example 2, using the fetched value from the database to enable the frame:
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
This code will throw the error:
Illegal parameter number in definition of beamer@@@temp. end{frame}
beamer presentations datatool
add a comment |
I want to use the value of a flag imported from a datatool database (stored in an external .csv file) to enable (or disable) a beamer frame.
The .csv file is of the form:
begin{filecontents*}{test.csv}
test enable
test1 ok
test2 ok
test3 ok
end{filecontents*}
Imported into a datatool database :
DTLloaddb{test}{test.csv}
My command:
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
I'm trying to use the frameIsEnabled
command to enable the frame fetching the database value:
begin{frame}<presentation: frameIsEnabled{DTLfetch{test}{test1}{enable}}>
But latex is not happy. I suppose there is something wrong related to the format of the fetched value DTLfetch{test}{test1}{enable}
.
If I display it (i.e. in a table or text) it returns zero (i.e. the comparison with the string "ok" returns false
).
Here's a minimal example to reproduce my problem.
Example 1, to verify the comparison of the "enable" flag with the string "ok":
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:1>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
Within this code, the frameIsEnabled
command will return 0
, while the desired output is 1
Example 2, using the fetched value from the database to enable the frame:
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
This code will throw the error:
Illegal parameter number in definition of beamer@@@temp. end{frame}
beamer presentations datatool
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54
add a comment |
I want to use the value of a flag imported from a datatool database (stored in an external .csv file) to enable (or disable) a beamer frame.
The .csv file is of the form:
begin{filecontents*}{test.csv}
test enable
test1 ok
test2 ok
test3 ok
end{filecontents*}
Imported into a datatool database :
DTLloaddb{test}{test.csv}
My command:
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
I'm trying to use the frameIsEnabled
command to enable the frame fetching the database value:
begin{frame}<presentation: frameIsEnabled{DTLfetch{test}{test1}{enable}}>
But latex is not happy. I suppose there is something wrong related to the format of the fetched value DTLfetch{test}{test1}{enable}
.
If I display it (i.e. in a table or text) it returns zero (i.e. the comparison with the string "ok" returns false
).
Here's a minimal example to reproduce my problem.
Example 1, to verify the comparison of the "enable" flag with the string "ok":
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:1>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
Within this code, the frameIsEnabled
command will return 0
, while the desired output is 1
Example 2, using the fetched value from the database to enable the frame:
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
This code will throw the error:
Illegal parameter number in definition of beamer@@@temp. end{frame}
beamer presentations datatool
I want to use the value of a flag imported from a datatool database (stored in an external .csv file) to enable (or disable) a beamer frame.
The .csv file is of the form:
begin{filecontents*}{test.csv}
test enable
test1 ok
test2 ok
test3 ok
end{filecontents*}
Imported into a datatool database :
DTLloaddb{test}{test.csv}
My command:
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
I'm trying to use the frameIsEnabled
command to enable the frame fetching the database value:
begin{frame}<presentation: frameIsEnabled{DTLfetch{test}{test1}{enable}}>
But latex is not happy. I suppose there is something wrong related to the format of the fetched value DTLfetch{test}{test1}{enable}
.
If I display it (i.e. in a table or text) it returns zero (i.e. the comparison with the string "ok" returns false
).
Here's a minimal example to reproduce my problem.
Example 1, to verify the comparison of the "enable" flag with the string "ok":
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:1>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
Within this code, the frameIsEnabled
command will return 0
, while the desired output is 1
Example 2, using the fetched value from the database to enable the frame:
documentclass[6pt]{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
newcommand{frameIsEnabled}[1]{ifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}<presentation:frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
Comparison with "ok" returns frameIsEnabled{DTLfetch{testList}{testName}{test1}{enable}}.
end{frame}
end{document}
This code will throw the error:
Illegal parameter number in definition of beamer@@@temp. end{frame}
beamer presentations datatool
beamer presentations datatool
edited Jan 21 at 23:58
dsama
asked Jan 21 at 22:06
dsamadsama
133
133
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54
add a comment |
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54
add a comment |
1 Answer
1
active
oldest
votes
The problem is that the commands you use are not expandable. To worka round this problem one can combine https://tex.stackexchange.com/a/386503/36296 and https://tex.stackexchange.com/a/335489/36296
documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
%usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
usepackage{xparse}
ExplSyntaxOn
NewExpandableDocumentCommand{xifstrequal}{mmmm}
{
str_if_eq_x:nnTF { #1 } { #2 } { #3 } { #4 }
}
ExplSyntaxOff
newcommand{DTLfetchsave}[5]{%
edtlgetrowforvalue{#2}{dtlcolumnindex{#2}{#3}}{#4}%
dtlgetentryfromcurrentrow{dtlcurrentvalue}{dtlcolumnindex{#2}{#5}}%
let#1dtlcurrentvalue
}
newcommand{frameIsEnabled}[1]{xifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}
content...
end{frame}
DTLfetchsave{temp}{testList}{testName}{test1}{enable}%
begin{frame}<presentation:frameIsEnabled{temp}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
end{frame}
end{document}
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
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%2f471211%2fuse-datatool-input-to-enable-beamer-frame%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 the commands you use are not expandable. To worka round this problem one can combine https://tex.stackexchange.com/a/386503/36296 and https://tex.stackexchange.com/a/335489/36296
documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
%usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
usepackage{xparse}
ExplSyntaxOn
NewExpandableDocumentCommand{xifstrequal}{mmmm}
{
str_if_eq_x:nnTF { #1 } { #2 } { #3 } { #4 }
}
ExplSyntaxOff
newcommand{DTLfetchsave}[5]{%
edtlgetrowforvalue{#2}{dtlcolumnindex{#2}{#3}}{#4}%
dtlgetentryfromcurrentrow{dtlcurrentvalue}{dtlcolumnindex{#2}{#5}}%
let#1dtlcurrentvalue
}
newcommand{frameIsEnabled}[1]{xifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}
content...
end{frame}
DTLfetchsave{temp}{testList}{testName}{test1}{enable}%
begin{frame}<presentation:frameIsEnabled{temp}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
end{frame}
end{document}
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
add a comment |
The problem is that the commands you use are not expandable. To worka round this problem one can combine https://tex.stackexchange.com/a/386503/36296 and https://tex.stackexchange.com/a/335489/36296
documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
%usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
usepackage{xparse}
ExplSyntaxOn
NewExpandableDocumentCommand{xifstrequal}{mmmm}
{
str_if_eq_x:nnTF { #1 } { #2 } { #3 } { #4 }
}
ExplSyntaxOff
newcommand{DTLfetchsave}[5]{%
edtlgetrowforvalue{#2}{dtlcolumnindex{#2}{#3}}{#4}%
dtlgetentryfromcurrentrow{dtlcurrentvalue}{dtlcolumnindex{#2}{#5}}%
let#1dtlcurrentvalue
}
newcommand{frameIsEnabled}[1]{xifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}
content...
end{frame}
DTLfetchsave{temp}{testList}{testName}{test1}{enable}%
begin{frame}<presentation:frameIsEnabled{temp}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
end{frame}
end{document}
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
add a comment |
The problem is that the commands you use are not expandable. To worka round this problem one can combine https://tex.stackexchange.com/a/386503/36296 and https://tex.stackexchange.com/a/335489/36296
documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
%usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
usepackage{xparse}
ExplSyntaxOn
NewExpandableDocumentCommand{xifstrequal}{mmmm}
{
str_if_eq_x:nnTF { #1 } { #2 } { #3 } { #4 }
}
ExplSyntaxOff
newcommand{DTLfetchsave}[5]{%
edtlgetrowforvalue{#2}{dtlcolumnindex{#2}{#3}}{#4}%
dtlgetentryfromcurrentrow{dtlcurrentvalue}{dtlcolumnindex{#2}{#5}}%
let#1dtlcurrentvalue
}
newcommand{frameIsEnabled}[1]{xifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}
content...
end{frame}
DTLfetchsave{temp}{testList}{testName}{test1}{enable}%
begin{frame}<presentation:frameIsEnabled{temp}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
end{frame}
end{document}
The problem is that the commands you use are not expandable. To worka round this problem one can combine https://tex.stackexchange.com/a/386503/36296 and https://tex.stackexchange.com/a/335489/36296
documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
%usepackage{graphicx}
mode<presentation>{usetheme{Malmoe}}
usepackage{datatool}
usepackage{filecontents}
begin{filecontents*}{test.csv}
testName, enable
test1, ok
test2, ok
test3, ok
end{filecontents*}
usepackage{xparse}
ExplSyntaxOn
NewExpandableDocumentCommand{xifstrequal}{mmmm}
{
str_if_eq_x:nnTF { #1 } { #2 } { #3 } { #4 }
}
ExplSyntaxOff
newcommand{DTLfetchsave}[5]{%
edtlgetrowforvalue{#2}{dtlcolumnindex{#2}{#3}}{#4}%
dtlgetentryfromcurrentrow{dtlcurrentvalue}{dtlcolumnindex{#2}{#5}}%
let#1dtlcurrentvalue
}
newcommand{frameIsEnabled}[1]{xifstrequal{#1}{ok}{1}{0}}
DTLloaddb[headers={testName, enable}]{testList}{test.csv}
title{My Presentation}
begin{document}
begin{frame}
content...
end{frame}
DTLfetchsave{temp}{testList}{testName}{test1}{enable}%
begin{frame}<presentation:frameIsEnabled{temp}>
Test1 enable flag is "DTLfetch{testList}{testName}{test1}{enable}".
end{frame}
end{document}
edited Jan 22 at 0:36
answered Jan 22 at 0:24
samcartersamcarter
88.3k798284
88.3k798284
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
add a comment |
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
This works perfectly, thank you very much!
– dsama
Jan 22 at 0:48
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%2f471211%2fuse-datatool-input-to-enable-beamer-frame%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
Thank you very much for your answer / suggestion. I've edited my question with a code sample to reproduce the bug
– dsama
Jan 21 at 22:54