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 use LaTeX occassionally, but not sure how to get the hypperref text fields to tab up properly. I got sick of using OpenOffice/LibreOffice to convert out PDF's that suck and have poorly done text boxes. The Ooo document looks like so.

enter image description here

And this is the LaTeX doc I am working with below, and what it currently looks like. I want to get something with similar clean, tabbed spacing. Any pointers? I tried scanning the hyperref docs, but I did not find what I was looking for or Google did not real smile at me today.

enter image description here

\documentclass[a4paper,11pt]{article}

\usepackage{hyperref}

\hypersetup{
pdfauthor = {My Name},
pdftitle = {Blah blah blah},
pdfsubject = {Blah blah blah},
pdfkeywords = {Blah, blah, blah},
pdfcreator = {LaTeX with hyperref package},
pdfproducer = {TexWorks 0.4.3 r857 via MikTeX 2.9}}

\def \textfieldwidth {3in}

\begin{document}

\begin{Form}
\begin{tabular}{l}
    \TextField[name=EmployeeName,width=\textfieldwidth]{Employee Name:} \\\\
    \TextField[name=EmployeeEmail,width=\textfieldwidth]{Employee E-mail:} \\\\
share|improve this question

1 Answer 1

up vote 2 down vote accepted

Here is one way to change things. The \AdjustSize macro uses \makebox to enclose the label text in a box of width specified in \LabelWidth so that all the labels are the same size. If you have larger labels you can adjust that setting.

If you do not want to specify a fixed width you could compute the \LabelWidth if you know the largest text by commenting out the \setlength... and using the \settowidth....

Here is the MWE with the fixed width setting:

\documentclass[a4paper,11pt]{article}

\usepackage{hyperref}

\hypersetup{
pdfauthor = {My Name},
pdftitle = {Blah blah blah},
pdfsubject = {Blah blah blah},
pdfkeywords = {Blah, blah, blah},
pdfcreator = {LaTeX with hyperref package},
pdfproducer = {TexWorks 0.4.3 r857 via MikTeX 2.9}}

\def\textfieldwidth{3.5in}%

\newlength{\LabelWidth}%
\setlength{\LabelWidth}{1.3in}%
%\settowidth{\LabelWidth}{Employee E-mail:}%  Specify the widest text here.

% Optional first parameter here specifies the alignment of
% the text within the \makebox.  Default is [l] for left 
% alignment. Other options are [r] and [c] for right and center
\newcommand*{\AdjustSize}[2][l]{\makebox[\LabelWidth][#1]{#2}}%

\begin{document}

\begin{Form}
\begin{tabular}{lr}
    \TextField[name=EmployeeName,width=\textfieldwidth]{\AdjustSize[l]{Employee Name:}} \\\\
    \TextField[name=EmployeeEmail,width=\textfieldwidth]{\AdjustSize{Employee E-mail:}} \\\\
\end{tabular}
\end{Form}
\end{document}
share|improve this answer
    
Cool, I will check this out tomorrow morning at work. Thanks a million. –  ajstein Sep 17 '11 at 14:52
    
Did the trick, thank you! –  ajstein Sep 18 '11 at 10:17

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.