How can I easily create a box with Latex?

By Alvin J. Alexander, devdaily.com

Okay, now I'm getting into the crazy stuff. I'm converting HTML prototypes into Latex so I can include the prototypes in my Requirements Specification docs.

So, that being my motivation, here's some code that shows how to display the equivalent of a textfield inside of a table. At the very least, this demonstrates how to use the fbox command. :)

\documentclass[11pt,a4paper]{report}

\usepackage[pdftex]{graphicx}

\begin{document}

%
% here's one box before the table
%
\fbox{some text here} \\

%
% here's a box inside of a table. 
% it works when using pdflatex to generate a pdf.
%
\begin{tabular}{|l|c|r|}
 \hline
\fbox{some stuff in a box} & blah & blah\\
 \hline
text & text & text\\
 \hline
text & text & text\\
 \hline
 C++ & A difficult language. & R4C3\\ 
 \hline
\end{tabular}

\end{document}

Note that this creates a box with borders around it, and looks remarkably like a textfield in HTML. Exactly what I want. FWIW, I can also simulate buttons, checkboxes, and other widgets. Sick, I know ... but fun.

 


devdaily logo