表单:如何将表单字段完美地放入多列单元格中?

表单:如何将表单字段完美地放入多列单元格中?

我有一个后续问题:表单:如何将表单字段完美地放入表格单元格中?

如果我使用多列,计算方法会再次崩溃。

我应该做些什么不同的事情?

在此处输入图片描述

\documentclass[fontsize=14pt]{scrreprt}
\usepackage{tabularx}
  \setlength\arrayrulewidth{1pt}
\usepackage{xcolor}
\usepackage{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}%
}

\begin{document}

\begin{Form}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{0.5\textwidth} | X |}
\hline
 \Name &  \Career \\ \hline
 \multicolumn{2}{| l |}{\Career}              \\ \hline
\end{tabularx} \par
\end{Form}

\end{document}

答案1

正如这里所建议的由于乳胶中的多列导致列间距错误,您可以使用固定宽度的多列:

\multicolumn{2}{| p{\dimexpr\linewidth-2\arrayrulewidth-2\tabcolsep} |}

我减去规则的宽度和内部填充以适应线宽。MWE:

\documentclass[fontsize=14pt]{scrreprt}
\usepackage{tabularx}
  \setlength\arrayrulewidth{1pt}
\usepackage{xcolor}
\usepackage{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}%
}

\begin{document}

\begin{Form}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{0.5\textwidth} | X |}
\hline
 \Name &  \Career \\ \hline
 \multicolumn{2}{| p{\dimexpr\linewidth-2\arrayrulewidth-2\tabcolsep} |}{\Career}              \\ \hline
\end{tabularx} \par
\end{Form}

\end{document}

MWE 结果

相关内容