使用 LaTeX 的 PDF 表单:如何创建宽度恰好为 4 英寸的 \TextField?
我正在使用 PDFLaTeX 创建表单,并遇到了定义输入字段的 \TextField 宏的问题:
\TextField[width=4in,name=sample]{}
结果字段比 4 英寸宽一点,我不明白为什么。以下示例通过导致溢出的水平盒(通过溢出规则突出显示)来说明该问题。
\documentclass[a4paper,11pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[pdftex]{hyperref}
\overfullrule3pt
\begin{document}
\noindent \TextField[name=one, width=\hsize]{type here:}
\end{document}
尽管已准确指定可用空间作为所需宽度,生成的 PDF 仍将显示过满的输入字段。
I'm using PDFLaTeX to create forms and ran into a problem with the \TextField macro that defines input fields:
\TextField[width=4in,name=sample]{}
The resulting field is a little wider than 4 inches and I don't understand why. The following example illustrates the problem by resulting in an overfull hbox which gets highlighted by an overfull rule.
\documentclass[a4paper,11pt]{article}
\usepackage[latin1]{inputenc}
\usepackage[pdftex]{hyperref}
\overfullrule3pt
\begin{document}
\noindent \TextField[name=one, width=\hsize]{type here:}
\end{document}
The resulting PDF will show an overfull input field despite having specified exactly the available space as the desired width.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
hyperref 包的作者 Heiko Oberdiek 给我发了一封电子邮件,并解释了为什么宽度默认大于指定值。每个 \TextField 都通过以下宏进行布局:
因此,我们最终得到标签、空格和输入字段。宽度参数仅影响输入字段。通过重新定义布局,我们可以确保最终得到指定的所需宽度:
此布局只需放下标签(“在此处键入:”)即可到达所需宽度的输入字段。
The author of the hyperref package, Heiko Oberdiek, sent me an email and explained why the width is by default greater than specified. Each \TextField is passed through the following macro for layout:
Hence, we end up with the label, a space, and the input field. The width parameter only affects the input field. By re-defining the layout, we can ensure that we end up with the desired width as specified:
This layout would simply drop the label ("type here:") to arrive at an input field of the desired width.