[texhax] [hyperref] Programatically change the name of the \CheckBox?

Hubert Lam hubert at lamfamily.info
Thu Nov 27 12:45:48 CET 2014


Dear Heiko

All I could say is, a HUGE thanks for spotting the recursion in the code!

The next problem: how many of these \CheckBox 's can I have without blowing out TeX's memory? LuaLaTeX is not on the agenda -- it just doesn't like PSTricks either :(

Many thanks.

Hubert




________________________________________
From: texhax <texhax-bounces at tug.org> on behalf of Heiko Oberdiek <heiko.oberdiek at googlemail.com>
Sent: Wednesday, 26 November 2014 3:47 AM
To: texhax at tug.org
Subject: Re: [texhax] [hyperref] Programatically change the name of the \CheckBox?

Hello,

On 26.11.2014 12:50, Hubert Lam wrote:
> Hi all
>
>
>
> Does anyone know of ways to programmatically changing the name of the
> \CheckBox?

Yes, it is possible.

> i.e. I would like the name of the \CheckBox to advance with the
> \theenumi counter. However, if I use
>
>
>
> \CheckBox[name=Name\theenumi]{}
>
>
>
> Then it fail to compile, resulting in an error about “Use of \pdfmark@
> doesn’t match its definition”.

The definition of `\theenumi` is not appropriate, in contrary
you have a recursion: "label=\protect\CheckBoxes\arabic*."
defines \theenumi. If \theenumi is called within the \CheckBox,
then it calls \CheckBoxes at the start of the label `\theenumi
and expands further another \CheckBox, which again wants to
have \theenumi in its name.

But you can use the counter value `enumi' instead.
However, \value is redefined, thus \countervalue/\thevalue
are using the original \value:

\documentclass[a4paper,12pt]{article}
\usepackage{calc}
\usepackage{enumitem}
\usepackage{pstricks-add}
\usepackage{hyperref}
\usepackage[margin=1in]{geometry}

\newcommand*{\countervalue}{}
\let\countervalue\value
\newcommand*{\thevalue}{\the\countervalue}

\begin{document}

\newcommand{\Checks}{
\begin{Form}
\CheckBox[name=7N\thevalue{enumi}]{}
\CheckBox[name=7R\thevalue{enumi}]{}
\CheckBox[name=7T\thevalue{enumi}]{}
\CheckBox[name=7H\thevalue{enumi}]{}
\CheckBox[name=7S\thevalue{enumi}]{}
\end{Form}
}

\newcommand{\Placehold}{How are you? }

\newcommand{\CheckBoxes}{%
\begin{minipage}{\widthof{\Checks}}
    \Checks
\end{minipage}
}

\begin{flushleft}
\tracingmacros=1
\begin{enumerate}[label={\protect\CheckBoxes \arabic*.},leftmargin=*]
\item   \psLoop{15}{\Placehold}
        \begin{enumerate}
        \item   \psLoop{20}{\Placehold}
        \item   \psLoop{10}{\Placehold}
        \item   \psLoop{10}{\Placehold}
        \item   \psLoop{10}{\Placehold}
        \end{enumerate}
\item   \psLoop{35}{\Placehold}
\end{enumerate}
\end{flushleft}
\end{document}

Yours sincerely
  Heiko
_______________________________________________
TeX FAQ: http://www.tex.ac.uk/faq
Mailing list archives: http://tug.org/pipermail/texhax/
More links: http://tug.org/begin.html

Automated subscription management: http://tug.org/mailman/listinfo/texhax
Human mailing list managers: postmaster at tug.org



More information about the texhax mailing list