Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am writing this question after seeing this one as I had no idea that you could make forms like that in TeX.

Playing a bit with the code in that example I came across two issues I could not find how to change with the \TextField[parameters]{label}environment.

How to set the number of lines in a multiline environment and how to move the label at the top rather than the bottom of the multiline box.

According to the manual the option for the multiline environment is just a boolean parameter

multiline boolean false whether text box is multiline

and the label appears at the bottom rather than the top.

share|improve this question

1 Answer 1

up vote 1 down vote accepted
  1. To specify the height of a multiline text fielf, use the optional argument height, such as

    \TextField[multiline=true,height=6\baselineskip,...]{Comments}\\
    
  2. For vertical alignment, you could use \height which gives he height of a box, together with \raisebox, such as

    \renewcommand*{\LayoutTextField}[2]{\makebox[6em][l]{#1: }%
      \raisebox{\baselineskip}{\raisebox{-\height}{#2}}}
    
  3. You could even adjust the default height of a multiline text field, like

    \renewcommand*{\DefaultHeightofTextMultiline}{6\baselineskip} 
    

Here's a complete example for this, re-using the code of the linked question:

\documentclass{article}
\usepackage{hyperref}
\renewcommand*{\DefaultHeightofTextMultiline}{6\baselineskip} 
\renewcommand*{\LayoutTextField}[2]{\makebox[6em][l]{#1: }%
  \raisebox{\baselineskip}{\raisebox{-\height}{#2}}}
%\renewcommand*{\LayoutTextField}[2]{% or this or similar ...
  %\raisebox{-\height}{\makebox[6em][l]{#1: }}\raisebox{-\height}{#2}}
\def\LayoutChoiceField#1#2{\makebox[6em][l]{#1: }#2}
\newdimen\longline
\longline=\textwidth\advance\longline-6em
\begin{document}
\begin{Form}
\TextField[name=Name,width=\longline,borderwidth=0,bordersep=4pt,
  backgroundcolor={.85 .85 .85}]{Name}\vskip1ex

\TextField[name=Affiliation,width=\longline,borderwidth=0,
  backgroundcolor={.85 .85 .85},]{Affiliation}\vskip1ex

\ChoiceMenu[borderwidth=0,radio=true,
  backgroundcolor={.85 .85 .85}]{Are you a}{Student, Academic}\\

\TextField[name=Comment,multiline=true,height=6\baselineskip,
  width=\longline,borderwidth=0,backgroundcolor={.85 .85 .85}]{Comments}\\
\end{Form}
\end{document}

enter image description here

share|improve this answer
    
Is there a particular reason that the same code does not provide the same results with XeLatex? Everything appears to be misaligned again. I am using Xelatex for the fontspec package as I am trying to use a system font not available to pdftex –  o4tlulz Jun 16 '12 at 10:05
    
@o4tlulz Interesting! I noticed that too. However, it works fine with LuaLaTeX. Could you use that? –  Stefan Kottwitz Jun 16 '12 at 17:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.