TransWikia.com

Problem with the select/deselect of radio buttons once all the options are selected one-by-one

TeX - LaTeX Asked by Bilal Azam on December 24, 2020

I am using radiobuttons ( ChoiceMenu[radio,…] ) and make them completely deselectable by removing the "Radio" flag using instructions from the following link:

http://tex.stackexchange.com/a/74543/3323

But here comes and other issue.

If I select and deselect all the options (A,B,C,D) one-by-one and then select option A again, it selects/deselects all the options at once.

Sample code is shown below.

documentclass{article}
usepackage{amsmath}
usepackage{amssymb}
usepackage{amsfonts}
usepackage{mathtools}
usepackage{enumitem}
usepackage[utf8]{inputenc}
usepackage[hidelinks,bookmarks=false]{hyperref}
usepackage{xcolor}
usepackage{etoolbox}

makeatletter
patchcmd{HyField@FlagsRadioButton}{HyField@SetFlag{Ff}{Radio}}{}{}{}
makeatother
defDefaultOptionsofRadio{print}

begin{document}

Select the Einstein's mass energy equivalence.
begin{enumerate}[label=(Alph*)]
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$F = ma$}{}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$F = dfrac{dp}{dt}$}{}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$E = hf$}{}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$E = mc^2$}{}}
end{enumerate}

end{document}

Is there any solution to this?
Thank you in advance.

One Answer

Your example is missing the initialization with begin{Form} or Form.

Beside this: you are using a texorpdfstring with empty second argument, that means that all fields have the same value in the pdf. If you add there something unique it works.

documentclass{article}
usepackage{amsmath}
usepackage{amssymb}
usepackage{amsfonts}
usepackage{mathtools}
usepackage{enumitem}
usepackage[utf8]{inputenc}
usepackage[hidelinks,bookmarks=false]{hyperref}
usepackage{xcolor}
usepackage{etoolbox}

makeatletter
patchcmd{HyField@FlagsRadioButton}{HyField@SetFlag{Ff}{Radio}}{}{}{}
makeatother
defDefaultOptionsofRadio{print}

begin{document}
Form % initialization
Select the Einstein's mass energy equivalence.
begin{enumerate}[label=(Alph*)]
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$F = ma$}{a}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$F = dfrac{dp}{dt}$}{b}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$E = hf$}{c}}
    item ChoiceMenu[radio,radiosymbol=ding{52},name=myGroupOfRadiobuttons]{}{texorpdfstring{$E = mc^2$}{d}}
end{enumerate}

end{document}

But this is clearly against the pdf reference, radio buttons should have the flag set, so you are relying on some undocumented side effect.

Correct answer by Ulrike Fischer on December 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP