Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This may seem basic, but is there a way to make checkboxes ticked automatically? E.g.

\documentclass{minimal}
\usepackage{hyperref}

\begin{document}
\begin{Form}

\CheckBox[name=ch1]{Yes}

\end{Form}
\end{document}

giving enter image description here

I'd like the above to be checked by default. Then in the .pdf one can uncheck it by clicking on the box as required.

I'm reading the hyperref manual and under 6.2 Forms optional parameters it lists the option with default as checked boolean false - I'm not sure how to pass this into \begin{Form} with a new default.

If there's an alternative method not involving hyperref I'm open to that also.

Am using EMACS & Auctex. If this is possible and there's some simpler way I could have looked it up (e.g. show/modify defaults for Form environment) up would be grateful for any pointers.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

The check box must have the option checked:

\documentclass{minimal}
\usepackage{hyperref}

\begin{document}
\begin{Form}
\CheckBox[checked,name=ch1]{Yes}

\end{Form}
\end{document}

For change the default you can use in the preamble:

\makeatletter
\Fld@checkedtrue
\makeatother

Or only for some form:

\documentclass{minimal}
\usepackage{hyperref}

\begin{document}

\begin{Form}
\makeatletter\Fld@checkedtrue\makeatother 
\CheckBox[name=ch1]{Yes}
\CheckBox[name=ch1]{No}
\end{Form}


\begin{Form}
\makeatletter\Fld@checkedfalse\makeatother 
\CheckBox[name=ch1]{Yes}
\CheckBox[name=ch1]{No}
\end{Form}

\end{document}
share|improve this answer
    
Great, perfect! What lead you to this answer ? (I'm still not getting it from the docs). I'm wondering if I can set it as an environment default as I have many boxes... Also, is this a general principle - i.e. if an environment has a default like checked false then is it reversed by using checked? –  dardisco Oct 6 '13 at 4:35
1  
@dardisco I just tried to do in this way and see what happen :). Change the default option is less intuitive, but see the updated answer. –  Fran Oct 6 '13 at 5:17
    
Thanks again, even better. Works fine so the rest is academic. It seems you're temporarily making Fld@checked mean Fldatchecked before calling CheckBox is this correct? How would I have been able to tell that the name of the variable I'm trying to change is Fldatchecked - is this related to the Form environment or the .pdf format? –  dardisco Oct 6 '13 at 5:36
1  
@dardisco see What do \makeatletter and \makeatother do? As far I know is not documented how to use \Fld@checked but browsing in .sty files sometimes you can imagine tricks like this one. –  Fran Oct 6 '13 at 6:02
    
Yes, I was reading this one before you suggested. Quite the imagination! * looks at .sty files * –  dardisco Oct 6 '13 at 6:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.