Use datatool input to enable beamer frame












2















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}









share|improve this question

























  • 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
















2















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}









share|improve this question

























  • 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














2












2








2








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}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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










1 Answer
1






active

oldest

votes


















1














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}





share|improve this answer


























  • This works perfectly, thank you very much!

    – dsama
    Jan 22 at 0:48











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
});


}
});














draft saved

draft discarded


















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









1














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}





share|improve this answer


























  • This works perfectly, thank you very much!

    – dsama
    Jan 22 at 0:48
















1














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}





share|improve this answer


























  • This works perfectly, thank you very much!

    – dsama
    Jan 22 at 0:48














1












1








1







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}





share|improve this answer















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}






share|improve this answer














share|improve this answer



share|improve this answer








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



















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?