看看我用 创建的文本框hyperref
。我的文档中有超过 600 个文本字段,其中一些字段不断变化。有没有办法hperref
自动分配文本字段的名称?
\begin{table}[!h]
\tymin=50pt
\tymax=\textwidth
\caption{ASUS Rog Rampage VI Extreme Encore - Erklärung der Rückseitenanschlüsse}
\begin{tabulary}{18cm}{|L|L|L|}
\hline
Nr & Bezeichnung & Erklärung\\\hline
%\parbox[POS][HÖHE][POS-INNEN]{BREITE}{INHALT}
1 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field1,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field2,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
2 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field3,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field4,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
3 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field5,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field6,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
4 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field7,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field8,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
5 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field9,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field10,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
6 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field11,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field12,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
7 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field13,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field14,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
8 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field15,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field16,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
9 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field17,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field18,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
10 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field19,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field20,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
11 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field21,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field22,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
12 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field23,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field24,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
13 & \makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=field25,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} & \makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=field26,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}\\ \hline
\end{tabulary}
\end{table}
答案1
我将定义一个自定义宏,以整数作为参数并输出一个完整的表格行,该行由行号和具有适当名称的必要字段组成。如果将其与计数器结合使用,您甚至不需要每次都输入数字。
在以下示例中,我定义了一个新的计数器tablrownum
,其初始设置为 1。\tablrow
如果没有提供显式参数,则此计数器的值将作为宏的参数。每次调用时\tablrow
,计数器都会增加一。如果提供了显式参数,则计数器将设置为此参数的值(并增加一)。
请注意,您需要在环境内将计数器重置为 1,tabluary
因为tabulary
将多次运行环境的内容,每次都会增加计数器。
字段会自动命名nameX
,descX
其中X
是表行的编号(或使用可选参数明确声明的编号\tablrow
)。
\documentclass{article}
\usepackage[margin=1.25cm]{geometry}
\usepackage{xcolor}
\usepackage{tabulary}
\usepackage{makecell}
\usepackage{hyperref}
\newcounter{tablrownum}
\newcommand{\tablrow}[1][\thetablrownum]{
#1 &
\makecell[l]{\parbox[0pt][1cm][t]{7cm}{\TextField[name=name#1,width=6cm,height=1cm,multiline=true, bordercolor=black]{}}} &
\makecell[l]{\parbox[0pt][1cm][t]{10cm}{\TextField[name=desc#1,width=9cm,height=1cm,multiline=true, bordercolor=black]{}}}
\ifnum#1=\thetablrownum\stepcounter{tablrownum}\else\setcounter{tablrownum}{\numexpr#1+1\relax}\fi
}
\begin{document}
\begin{table}[!h]
\tymin=50pt
\tymax=\textwidth
\caption{ASUS Rog Rampage VI Extreme Encore -- Erklärung der Rückseitenanschlüsse}
\begin{tabulary}{18cm}{|L|L|L|}
\hline\setcounter{tablrownum}{1}
Nr & Bezeichnung & Erklärung \\ \hline
\tablrow \\ \hline
\tablrow \\ \hline
\tablrow \\ \hline
\tablrow \\ \hline
\tablrow \\ \hline
\tablrow[20] \\ \hline
\tablrow \\ \hline
\end{tabulary}
\end{table}
\end{document}