hyperref Choicemenu 调整多个按钮之间的空间

hyperref Choicemenu 调整多个按钮之间的空间

我正在尝试使用 hyperref 包创建一个可填写的表单。问题是我想扩展所有 \ChoiceMenu 中彼此对齐的单选按钮之间的空间。因为这样我就可以把类别放在它们上面。你有什么建议?

\documentclass{article}
\usepackage[letterpaper, landscape, margin=1in]{geometry}
\usepackage{hyperref}

\begin{document}
\begin{Form}
\def\DefaultWidthofChoiceMenu{9cm}%
\def\DefaultHeightofChoiceMenu{0.8\baselineskip}
\def\DefaultWidthofChoiceMenu{0.8\baselineskip}
\def\DefaultHeightofText{1.2\baselineskip}
                                             Never   Rarely   Once in a While  Fairly Often Always\\                                                        
  \begin{tabular}{@{}p{10cm}p{10cm}@{}}                                                                 
\rule{0pt}{4ex}1.) helps me when I need it. &\ChoiceMenu[name=optionB,radio,radiosymbol=, align = 2]{}{,,,,,,,} \\
\rule{0pt}{4ex}
2.) would make me feel comfortable in a new situation.&\ChoiceMenu[name=optionA,radio,radiosymbol=, align = 2]{}{,,,,,,,}\\
\end{tabular}
\end{Form}
\end{document}

答案1

与其使用{,,,,,}选择按钮,不如插入一些占用一些空间的“空白”选择标签;下面我使用了\qquad

我不知道这与您的用例是否兼容,但我会尽可能地实现自动化。例如,使用大批包中您可以定义一种新的列类型,并让其(半)自动插入问题编号和选择菜单。我说半自动,是因为您仍然需要在每行末尾放置“&\”来插入选择按钮。

最后,我定义了一个\Choicemenu插入选择菜单的宏,根据问题编号name将 设置为optionAoptionB、 ...。这样做的好处是,如果您需要更改单选按钮,则只需在一个地方进行更改。

有了这个,你得到的输出是:

在此处输入图片描述

完整代码如下:

\documentclass{article}
\usepackage[letterpaper, landscape, margin=1in]{geometry}
\usepackage{hyperref}
\usepackage{array}
\usepackage{tabularx}
\newcounter{question}% a counter for the questions
\renewcommand\thequestion{\arabic{question}).\space}

% Define new column type that inserts the question number and the
% choice menu. It increments the question counter, inserts the 
% question number and then puts the choice menu at the end
\newcolumntype{Q}{>{\refstepcounter{question}\thequestion}p{120mm}r<{\Choicemenu}}

% Define a macro to insert the choice menu so that we only have to
% make changes to it in one place. The name is automatically set to
% optionA, optionB, ... based on the question number
\newcommand\Choicemenu{%
  \ChoiceMenu[name=option\Alph{question},
              radio,radiosymbol=,
              align=2,
              height=1mm,
              width=4mm]{}{\qquad,\qquad,\qquad,\qquad,\qquad}
}%

\def\arraystretch{1.2}
\begin{document}
% Not sure that these are necessary?
%\def\DefaultHeightofChoiceMenu{0.8\baselineskip}
%\def\DefaultWidthofChoiceMenu{0.8\baselineskip}
%\def\DefaultHeightofText{.92\baselineskip}
\begin{Form}
  \begin{tabularx}\textwidth{@{}Q@{}}
    \multicolumn{2}{r}{Never Rarely Sometimes Often Always}\\
    Helps me when I need it&\\
    Would make me feel comfortable in a new situation&\\
\end{tabularx}
\end{Form}
\end{document}

请注意,环境\multicoumn的第一行必须tabular覆盖Q列类型。

相关内容