我能做什么文本域s 等(除了一个小的“外部分隔符”)是否完全适合表格单元格(具有其设定的尺寸)?
\documentclass[fontsize=14pt]{scrreprt}
\usepackage{tabularx, xcolor}
\usepackage{hyperref}
% Style
\renewcommand*{\DefaultOptionsofText}{print, bordercolor=red,
borderstyle={U},
bordercolor={red},
backgroundcolor=lightgray!60
}
% Textfields
\def\Name{\mbox{\TextField[name=Name,height=1em, width=0.375\textwidth]{Name:}}%
}
\def\Career{\mbox{\TextField[name=Career,height=1em, width=0.375\textwidth]{Career:}}%
}
\usepackage{mwe}
\begin{document}
\begin{Form}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{0.5\textwidth} | X |}
\hline
\Name & \Career \\ \hline
\end{tabularx} \par
\end{Form}
\end{document}
答案1
通过测量标签可以相当轻松地确定宽度。高度则比较困难:最佳值还取决于使用的 pdf 查看器以及您想要实现的确切视觉效果。
\documentclass[fontsize=14pt]{scrreprt}
\usepackage{tabularx, xcolor,calc}
\usepackage{hyperref}
% Style
\renewcommand*{\DefaultOptionsofText}{print, bordercolor=red,
borderstyle={U},
bordercolor={red},
backgroundcolor=lightgray!60
}
% Textfields
\newlength\lentmpa
\newcommand\Name{%
\settowidth\lentmpa{Name: }%
\mbox{%
\TextField[name=Name,
height=\dimexpr\normalbaselineskip-4\arrayrulewidth,
width=\dimexpr\linewidth-\lentmpa]{Name:}}}
\newcommand\Career{\settowidth\lentmpa{Career: }%
\mbox{%
\TextField[name=Career,
height=\dimexpr\normalbaselineskip-4\arrayrulewidth,
width=\dimexpr\linewidth-\lentmpa]{Career:}}%
}
\def\LayoutTextField#1#2{% label, field
#1 \raisebox{-0.3\normalbaselineskip+2\arrayrulewidth}[0pt][0pt]{#2}%
}
\usepackage{mwe}
\begin{document}
\begin{Form}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{0.5\textwidth} | X |}
\hline
\Name & \Career \\ \hline
\end{tabularx} \par
\end{Form}
\end{document}