使用 LaTeX 的 PDF 表单:如何创建宽度恰好为 4 英寸的 \TextField?

发布于 2024-09-27 19:52:12 字数 457 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白馒头 2024-10-04 19:52:12

hyperref 包的作者 Heiko Oberdiek 给我发了一封电子邮件,并解释了为什么宽度默认大于指定值。每个 \TextField 都通过以下宏进行布局:

\def\LayoutTextField#1#2{% label, field
   #1 #2%
}

因此,我们最终得到标签、空格和输入字段。宽度参数仅影响输入字段。通过重新定义布局,我们可以确保最终得到指定的所需宽度:

\def\LayoutTextField#1#2{#2}

此布局只需放下标签(“在此处键入:”)即可到达所需宽度的输入字段。

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:

\def\LayoutTextField#1#2{% label, field
   #1 #2%
}

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:

\def\LayoutTextField#1#2{#2}

This layout would simply drop the label ("type here:") to arrive at an input field of the desired width.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文