首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >latex hyperref choicemenu框比为长文本指定的宽度大

latex hyperref choicemenu框比为长文本指定的宽度大
EN

Stack Overflow用户
提问于 2021-11-09 11:56:27
回答 1查看 98关注 0票数 1

我正在尝试使用MikTeX\LaTeX准备一个可填写的pdf-form。我使用来自hyperref包的ChoiceMenu来提供一个可供选择的列表。问题是,我希望字段的宽度为2厘米。我已经在ChoiceMenu的参数中指定了所需的宽度。到目前为止,没有问题。但是当我在列表中包含一个长度超过2厘米的选项时,ChoiceMenu字段变得比2厘米宽。有没有办法强制程序保持指定的宽度为2厘米,即使文本在选择后在字段中不完全可读?

下面是一个最小的工作示例:

代码语言:javascript
复制
\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} 
EN

回答 1

Stack Overflow用户

发布于 2021-11-09 12:13:56

您可以像这样隐藏文本的宽度:

代码语言:javascript
复制
\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} 

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69897719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档