Checkboxes and TextFields within Datatool csv tables












4














I've got a sample csv table with three columns - Pet, Names and Number. It's a list of Cats and Dogs, their respective names and the occurrence of each name.
i.e.



enter image description here



The order of Cats or Dogs in the csv file is completely random so I've use latex to effectively group all of one pet into its own table in the output document.



My document creates the two tables without issues. What I would like to do is have a Checkbox and TextField in the final column, however so far have always been getting the below error when trying to do so.




! Use of @sDTLforeach doesn't match its definition. @ifnextchar ...
reserved@d =#1def reserved@a {
#2}def reserved@b {#3}f... l.70 ...andafterdocsvlistexpandafter{uniquepet}
?




Document code below for reference.



Appreciate any help.





documentclass{article}
renewcommand{familydefault}{sfdefault}

usepackage[parfill]{parskip} % Do not indent paragraphs
usepackage{longtable, tabu}
usepackage{datatool}
usepackage{cellspace}
usepackage{makecell}
usepackage{booktabs}
usepackage{hyperref}

usepackage[a4paper,top=18mm,bottom=12mm,right=8mm,left=8mm,landscape]{geometry}

tabulinesep=0.8mm
setcellgapes{2pt}

begin{filecontents*}{Pet.csv}
Pet,Name,Number
Dog,Buddy,6305
Dog,Max,5719
Dog,Molly,5402
Cat,Sadie,3389
Cat,Jake,3159
Cat,Lucy,3039
Cat,Bear,2916
Dog,Jack,2703
Dog,Shadow,2537
Dog,Abby,2467
Cat,Rocky,2455
Cat,Toby,2313
Cat,Chloe,2290
end{filecontents*}

begin{document}
begin{Form}

DTLloadrawdb{Pets}{Pet.csv}%Load vocab file

newcommand*{uniquepet}{}
newcommand*{csvlistsep}{renewcommand{csvlistsep}{ ,}}
DTLforeach*{Pets}{Pet=Pet}{%
expandafterDTLifinlistexpandafter{Pet}{uniquepet}%
{}% do nothing, already in list
{% add to list
ifdefempty{uniquepet}%
{letuniquepetPet}% first element of list
{% append to list
eapptouniquepet{,Pet}%
}%
}%
}


newcommand{nextrow}{}
renewcommand{nextrow}{}
newcolumntype{Z}{>{raggedleftletnewline\arraybackslashhspace{0pt}}X}
renewcommand{do}[1]{%

bgroup
defarraystretch{1}
makegapedcells
begin{tabular}{c}
{hugebf Popular #1 Names}\
end{tabular}
egroup

CheckBox[width=1em]{Tick Box}
TextField{Alternative}

bgroup
small
begin{longtabu} to textwidth { @{} p{19mm} | p{24mm} | Z }
{bf Name} & {bf Occurance} & {bf Correct?} par Tick box or enter alternative \
toprule endhead
DTLforeach*{Pets}{Pet=Pet, Name=Name, Number=Number}
{ifnumpdfstrcmp{#1}{Pet}=0
eapptonextrow{Name & Number & noexpandCheckBox[width=1em]{Name} par Free Text Box noexpand\} % Collect rows
fi}%
nextrow % Print table row
bottomrule
end{longtabu}
egroup

clearpage
}

expandafterdocsvlistexpandafter{uniquepet}

end{Form}
end{document}









share|improve this question
























  • What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
    – Nicola Talbot
    Jan 29 at 21:10










  • Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
    – JTurn
    Jan 31 at 0:57






  • 1




    Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
    – Nicola Talbot
    Jan 31 at 15:05






  • 1




    If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
    – gvgramazio
    Jun 7 at 8:59
















4














I've got a sample csv table with three columns - Pet, Names and Number. It's a list of Cats and Dogs, their respective names and the occurrence of each name.
i.e.



enter image description here



The order of Cats or Dogs in the csv file is completely random so I've use latex to effectively group all of one pet into its own table in the output document.



My document creates the two tables without issues. What I would like to do is have a Checkbox and TextField in the final column, however so far have always been getting the below error when trying to do so.




! Use of @sDTLforeach doesn't match its definition. @ifnextchar ...
reserved@d =#1def reserved@a {
#2}def reserved@b {#3}f... l.70 ...andafterdocsvlistexpandafter{uniquepet}
?




Document code below for reference.



Appreciate any help.





documentclass{article}
renewcommand{familydefault}{sfdefault}

usepackage[parfill]{parskip} % Do not indent paragraphs
usepackage{longtable, tabu}
usepackage{datatool}
usepackage{cellspace}
usepackage{makecell}
usepackage{booktabs}
usepackage{hyperref}

usepackage[a4paper,top=18mm,bottom=12mm,right=8mm,left=8mm,landscape]{geometry}

tabulinesep=0.8mm
setcellgapes{2pt}

begin{filecontents*}{Pet.csv}
Pet,Name,Number
Dog,Buddy,6305
Dog,Max,5719
Dog,Molly,5402
Cat,Sadie,3389
Cat,Jake,3159
Cat,Lucy,3039
Cat,Bear,2916
Dog,Jack,2703
Dog,Shadow,2537
Dog,Abby,2467
Cat,Rocky,2455
Cat,Toby,2313
Cat,Chloe,2290
end{filecontents*}

begin{document}
begin{Form}

DTLloadrawdb{Pets}{Pet.csv}%Load vocab file

newcommand*{uniquepet}{}
newcommand*{csvlistsep}{renewcommand{csvlistsep}{ ,}}
DTLforeach*{Pets}{Pet=Pet}{%
expandafterDTLifinlistexpandafter{Pet}{uniquepet}%
{}% do nothing, already in list
{% add to list
ifdefempty{uniquepet}%
{letuniquepetPet}% first element of list
{% append to list
eapptouniquepet{,Pet}%
}%
}%
}


newcommand{nextrow}{}
renewcommand{nextrow}{}
newcolumntype{Z}{>{raggedleftletnewline\arraybackslashhspace{0pt}}X}
renewcommand{do}[1]{%

bgroup
defarraystretch{1}
makegapedcells
begin{tabular}{c}
{hugebf Popular #1 Names}\
end{tabular}
egroup

CheckBox[width=1em]{Tick Box}
TextField{Alternative}

bgroup
small
begin{longtabu} to textwidth { @{} p{19mm} | p{24mm} | Z }
{bf Name} & {bf Occurance} & {bf Correct?} par Tick box or enter alternative \
toprule endhead
DTLforeach*{Pets}{Pet=Pet, Name=Name, Number=Number}
{ifnumpdfstrcmp{#1}{Pet}=0
eapptonextrow{Name & Number & noexpandCheckBox[width=1em]{Name} par Free Text Box noexpand\} % Collect rows
fi}%
nextrow % Print table row
bottomrule
end{longtabu}
egroup

clearpage
}

expandafterdocsvlistexpandafter{uniquepet}

end{Form}
end{document}









share|improve this question
























  • What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
    – Nicola Talbot
    Jan 29 at 21:10










  • Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
    – JTurn
    Jan 31 at 0:57






  • 1




    Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
    – Nicola Talbot
    Jan 31 at 15:05






  • 1




    If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
    – gvgramazio
    Jun 7 at 8:59














4












4








4


2





I've got a sample csv table with three columns - Pet, Names and Number. It's a list of Cats and Dogs, their respective names and the occurrence of each name.
i.e.



enter image description here



The order of Cats or Dogs in the csv file is completely random so I've use latex to effectively group all of one pet into its own table in the output document.



My document creates the two tables without issues. What I would like to do is have a Checkbox and TextField in the final column, however so far have always been getting the below error when trying to do so.




! Use of @sDTLforeach doesn't match its definition. @ifnextchar ...
reserved@d =#1def reserved@a {
#2}def reserved@b {#3}f... l.70 ...andafterdocsvlistexpandafter{uniquepet}
?




Document code below for reference.



Appreciate any help.





documentclass{article}
renewcommand{familydefault}{sfdefault}

usepackage[parfill]{parskip} % Do not indent paragraphs
usepackage{longtable, tabu}
usepackage{datatool}
usepackage{cellspace}
usepackage{makecell}
usepackage{booktabs}
usepackage{hyperref}

usepackage[a4paper,top=18mm,bottom=12mm,right=8mm,left=8mm,landscape]{geometry}

tabulinesep=0.8mm
setcellgapes{2pt}

begin{filecontents*}{Pet.csv}
Pet,Name,Number
Dog,Buddy,6305
Dog,Max,5719
Dog,Molly,5402
Cat,Sadie,3389
Cat,Jake,3159
Cat,Lucy,3039
Cat,Bear,2916
Dog,Jack,2703
Dog,Shadow,2537
Dog,Abby,2467
Cat,Rocky,2455
Cat,Toby,2313
Cat,Chloe,2290
end{filecontents*}

begin{document}
begin{Form}

DTLloadrawdb{Pets}{Pet.csv}%Load vocab file

newcommand*{uniquepet}{}
newcommand*{csvlistsep}{renewcommand{csvlistsep}{ ,}}
DTLforeach*{Pets}{Pet=Pet}{%
expandafterDTLifinlistexpandafter{Pet}{uniquepet}%
{}% do nothing, already in list
{% add to list
ifdefempty{uniquepet}%
{letuniquepetPet}% first element of list
{% append to list
eapptouniquepet{,Pet}%
}%
}%
}


newcommand{nextrow}{}
renewcommand{nextrow}{}
newcolumntype{Z}{>{raggedleftletnewline\arraybackslashhspace{0pt}}X}
renewcommand{do}[1]{%

bgroup
defarraystretch{1}
makegapedcells
begin{tabular}{c}
{hugebf Popular #1 Names}\
end{tabular}
egroup

CheckBox[width=1em]{Tick Box}
TextField{Alternative}

bgroup
small
begin{longtabu} to textwidth { @{} p{19mm} | p{24mm} | Z }
{bf Name} & {bf Occurance} & {bf Correct?} par Tick box or enter alternative \
toprule endhead
DTLforeach*{Pets}{Pet=Pet, Name=Name, Number=Number}
{ifnumpdfstrcmp{#1}{Pet}=0
eapptonextrow{Name & Number & noexpandCheckBox[width=1em]{Name} par Free Text Box noexpand\} % Collect rows
fi}%
nextrow % Print table row
bottomrule
end{longtabu}
egroup

clearpage
}

expandafterdocsvlistexpandafter{uniquepet}

end{Form}
end{document}









share|improve this question















I've got a sample csv table with three columns - Pet, Names and Number. It's a list of Cats and Dogs, their respective names and the occurrence of each name.
i.e.



enter image description here



The order of Cats or Dogs in the csv file is completely random so I've use latex to effectively group all of one pet into its own table in the output document.



My document creates the two tables without issues. What I would like to do is have a Checkbox and TextField in the final column, however so far have always been getting the below error when trying to do so.




! Use of @sDTLforeach doesn't match its definition. @ifnextchar ...
reserved@d =#1def reserved@a {
#2}def reserved@b {#3}f... l.70 ...andafterdocsvlistexpandafter{uniquepet}
?




Document code below for reference.



Appreciate any help.





documentclass{article}
renewcommand{familydefault}{sfdefault}

usepackage[parfill]{parskip} % Do not indent paragraphs
usepackage{longtable, tabu}
usepackage{datatool}
usepackage{cellspace}
usepackage{makecell}
usepackage{booktabs}
usepackage{hyperref}

usepackage[a4paper,top=18mm,bottom=12mm,right=8mm,left=8mm,landscape]{geometry}

tabulinesep=0.8mm
setcellgapes{2pt}

begin{filecontents*}{Pet.csv}
Pet,Name,Number
Dog,Buddy,6305
Dog,Max,5719
Dog,Molly,5402
Cat,Sadie,3389
Cat,Jake,3159
Cat,Lucy,3039
Cat,Bear,2916
Dog,Jack,2703
Dog,Shadow,2537
Dog,Abby,2467
Cat,Rocky,2455
Cat,Toby,2313
Cat,Chloe,2290
end{filecontents*}

begin{document}
begin{Form}

DTLloadrawdb{Pets}{Pet.csv}%Load vocab file

newcommand*{uniquepet}{}
newcommand*{csvlistsep}{renewcommand{csvlistsep}{ ,}}
DTLforeach*{Pets}{Pet=Pet}{%
expandafterDTLifinlistexpandafter{Pet}{uniquepet}%
{}% do nothing, already in list
{% add to list
ifdefempty{uniquepet}%
{letuniquepetPet}% first element of list
{% append to list
eapptouniquepet{,Pet}%
}%
}%
}


newcommand{nextrow}{}
renewcommand{nextrow}{}
newcolumntype{Z}{>{raggedleftletnewline\arraybackslashhspace{0pt}}X}
renewcommand{do}[1]{%

bgroup
defarraystretch{1}
makegapedcells
begin{tabular}{c}
{hugebf Popular #1 Names}\
end{tabular}
egroup

CheckBox[width=1em]{Tick Box}
TextField{Alternative}

bgroup
small
begin{longtabu} to textwidth { @{} p{19mm} | p{24mm} | Z }
{bf Name} & {bf Occurance} & {bf Correct?} par Tick box or enter alternative \
toprule endhead
DTLforeach*{Pets}{Pet=Pet, Name=Name, Number=Number}
{ifnumpdfstrcmp{#1}{Pet}=0
eapptonextrow{Name & Number & noexpandCheckBox[width=1em]{Name} par Free Text Box noexpand\} % Collect rows
fi}%
nextrow % Print table row
bottomrule
end{longtabu}
egroup

clearpage
}

expandafterdocsvlistexpandafter{uniquepet}

end{Form}
end{document}






tables hyperref datatool






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 1 at 4:17

























asked Jan 7 at 21:30









JTurn

212




212












  • What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
    – Nicola Talbot
    Jan 29 at 21:10










  • Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
    – JTurn
    Jan 31 at 0:57






  • 1




    Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
    – Nicola Talbot
    Jan 31 at 15:05






  • 1




    If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
    – gvgramazio
    Jun 7 at 8:59


















  • What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
    – Nicola Talbot
    Jan 29 at 21:10










  • Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
    – JTurn
    Jan 31 at 0:57






  • 1




    Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
    – Nicola Talbot
    Jan 31 at 15:05






  • 1




    If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
    – gvgramazio
    Jun 7 at 8:59
















What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
– Nicola Talbot
Jan 29 at 21:10




What version do you have? Your MWE works fine for me with datatool version 2.29. (Unrelated, but I recommend you change bf to bfseries.)
– Nicola Talbot
Jan 29 at 21:10












Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
– JTurn
Jan 31 at 0:57




Hi @NicolaTalbot, yes the above MWE will work fine however if you replace 'Check Box' in the table cell with CheckBox[width=1em]{Tick Box} you'll notice you're unable to put a checkbox into the table.
– JTurn
Jan 31 at 0:57




1




1




Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
– Nicola Talbot
Jan 31 at 15:05




Then you need to update your MWE to demonstrate the error. Did you try noexpandCheckBox[width=1em]{Tick Box}?
– Nicola Talbot
Jan 31 at 15:05




1




1




If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
– gvgramazio
Jun 7 at 8:59




If you found the solution the question should be closed. You could also answer the question by yourself and accept it.
– gvgramazio
Jun 7 at 8:59










1 Answer
1






active

oldest

votes


















0














Needed to add noexpandCheckBox[width=1em]{Tick Box}






share|improve this answer

















  • 2




    For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
    – cfr
    Jun 11 at 1:35











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%2f409287%2fcheckboxes-and-textfields-within-datatool-csv-tables%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









0














Needed to add noexpandCheckBox[width=1em]{Tick Box}






share|improve this answer

















  • 2




    For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
    – cfr
    Jun 11 at 1:35
















0














Needed to add noexpandCheckBox[width=1em]{Tick Box}






share|improve this answer

















  • 2




    For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
    – cfr
    Jun 11 at 1:35














0












0








0






Needed to add noexpandCheckBox[width=1em]{Tick Box}






share|improve this answer












Needed to add noexpandCheckBox[width=1em]{Tick Box}







share|improve this answer












share|improve this answer



share|improve this answer










answered Jun 10 at 23:07









JTurn

212




212








  • 2




    For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
    – cfr
    Jun 11 at 1:35














  • 2




    For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
    – cfr
    Jun 11 at 1:35








2




2




For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
– cfr
Jun 11 at 1:35




For future reference, it would have been more courteous to ask the commentator who suggested this to write an answer rather than taking the credit yourself. However, I see that answering it yourself was suggested by another commentator, so obviously you couldn't know.
– cfr
Jun 11 at 1:35


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f409287%2fcheckboxes-and-textfields-within-datatool-csv-tables%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

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?