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.

Code:

\documentclass{article}
\usepackage{xcolor,hyperref}
\makeatletter
\def\Fld@bordercolor{0 0 0} % this works.
\makeatletter
\begin{document}
\begin{Form}
\setlength\unitlength{1cm}
  \begin{tabular}{|l|}
     \hline
     S + \makebox(4,1){\TextField[name=textfield,width=3cm,height=0.5cm]{Text}} \\
     \hline
  \end{tabular}
\end{Form}
\end{document}

Output:

enter image description here

The input box is shifted upwards. How to center it vertically, so it was on the same line with 'S +'?

share|improve this question
    
pdftex removed. –  user4035 Nov 16 '12 at 9:35
add comment

1 Answer

up vote 2 down vote accepted

Like this?

enter image description here

The code:

\documentclass{article}
\usepackage{xcolor,hyperref}
\makeatletter
\def\Fld@bordercolor{0 0 0} % this works.
\makeatletter
\begin{document}
\begin{Form}
\setlength\unitlength{1cm}
  \begin{tabular}{|l|}
     \hline
     \phantom{S}\makebox(4,1){ S+\TextField[name=textfield,width=3cm,height=0.5cm]{Text}} \phantom{S}\\
     \hline
  \end{tabular}
\end{Form}
\end{document}

Notice that \phantom{S} is used to get some extra white space before and after the TextField.


Here is also a TikZ-based solution: it requires also the xparse package.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{xparse}

% TexTForm: arguments:
% #1 (optional): first letter - default = S
% #2 (optional): text - default = Text
% #3 (mandatory): width (set also the unit, i.e. cm)
% #4 (mandatory): height (set also the unit, i.e. cm)
\NewDocumentCommand{\TexTForm}{O{S} O{Text} m m}{
\begin{tikzpicture}[baseline=-0.5ex,show background rectangle]
\node[draw, minimum width=#3, minimum height=#4] (form) {};
\node[left, align=left, yshift=1ex]at (form.south west)(text){#1 + #2};

\end{tikzpicture}
}

\begin{document}
\TexTForm{3cm}{0.5cm}\\[2ex]
\TexTForm[T][Other text]{4cm}{0.75cm}\\[2ex]
\TexTForm[Hello][Some other text]{5cm}{1cm}
\end{document}

The result:

enter image description here

share|improve this answer
add comment

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.