我正在尝试使用MikTeX\LaTeX准备一个可填写的pdf-form。我使用来自hyperref包的ChoiceMenu来提供一个可供选择的列表。问题是,我希望字段的宽度为2厘米。我已经在ChoiceMenu的参数中指定了所需的宽度。到目前为止,没有问题。但是当我在列表中包含一个长度超过2厘米的选项时,ChoiceMenu字段变得比2厘米宽。有没有办法强制程序保持指定的宽度为2厘米,即使文本在选择后在字段中不完全可读?
下面是一个最小的工作示例:
\documentclass[landscape]{scrartcl}
\usepackage[top=2cm, bottom=3cm, left=2cm, right=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
% begin document
\begin{document}
\begin{Form}
\begin{tabular}{l}
\mbox{\ChoiceMenu[combo, name=test_choice, width=2cm]{Working choice field (2 cm width):}{short 1, short 2}} \\\\
\mbox{\ChoiceMenu[combo, name=test_choice, width=2cm]{Non-working choice field (2 cm width):}{short 1, this is a very long sentence leading to a much greater field width than specified}}
\end{tabular}
\end{Form}
\end{document} 发布于 2021-11-09 12:13:56
您可以像这样隐藏文本的宽度:
\documentclass[landscape]{scrartcl}
\usepackage[top=2cm, bottom=3cm, left=2cm, right=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\newcommand{\hide}[1]{\texorpdfstring{\makebox[0pt]{#1}}{#1}}
% begin document
\begin{document}
\begin{Form}
\begin{tabular}{l}
\mbox{\ChoiceMenu[combo, name=testchoice, width=2cm]{Working choice field (2 cm width):}{short 1, short 2}} \\\\
\mbox{\ChoiceMenu[combo, name=testchoice, width=2cm]{Non-working choice field (2 cm width):}{short 1, \hide{this is a very long sentence leading to a much greater field width than specified}}}
\end{tabular}
\end{Form}
\end{document}

https://stackoverflow.com/questions/69897719
复制相似问题