[Tex/LaTex] Drawing a rectangle

diagrams

What is the easiest way to draw a rectangle on latex? I just need a simple rectangle for my students to enter the final answer of a question and I am hoping I don't have to learn anything fancy like Tikz.

Best Answer

You could just do something simple like this

\documentclass{article}
\newcommand\answerbox{%%
    \fbox{\rule{1in}{0pt}\rule[-0.5ex]{0pt}{4ex}}}
\pagestyle{empty}
\begin{document}

Put you answer here: \answerbox

\end{document}

which requires no use of TikZ.

enter image description here

A bit of an explanation.

The syntax for \rule is as follows:

\rule[<lift>]{<width>}{<height>}

I use two separate \rule commands because if I wrote something like

\rule{1in}{4ex}

I just get a solid black box defeating the purpose.

By using a negative value for <lift> I can drop the bottom of the box below the baseline.

\fbox then adds more space. These values are controlled with the following lengths

\fboxrule
\fboxsep

Generally, \fboxrule is 0.4pt and \fboxsep is 3pt, but you can adjust those values as desired.

Related Question