Drawing a rectangle
Nothing fancy with tikz
. It is easy (this answer is for just showing it).
\documentclass{article}
\usepackage{tikz}
\begin{document}
Your answer: \tikz[baseline=0.6ex]\draw (0,0) rectangle (10cm,3ex);
Your answer: \tikz[baseline=-4pt]\node[draw,minimum width=10cm,minimum height=3ex] {};
\end{document}
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
.
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.
Actually, if all you want is a box for an answer, I'd say tikz might actually be the most readable (syntactically, at least) way to do this.
A box as wide as the text, 1in tall, is just:
\tikz \draw (0,0) rectangle (\linewidth, 1in);
The point (0,0) just references the current position in the text, then \linewidth
gives it the right width (which will adjust if you change your margins, and then just set the height, 1in
is just arbitrary.
Make sure to use \noindent
before beginning the picture, as it will try to indent the drawing and that'll cause weird alignment issues.
Here's a simple MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
% question here
\lipsum[1]
\noindent\\
\tikz \draw (0,0) rectangle (\linewidth, 1in);
\end{document}
You could also use standard \begin{tikzpicture}
\end{tikzpicture}
brackets like with any other environment, but I used \tikz
instead because this drawing is only one line long. The draw command is one line long either way.
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\noindent\\
\begin{tikzpicture}
\draw (0,0) rectangle (\linewidth, 1in);
\end{tikzpicture}
\end{document}
I know you asked for something other than tikz
, but I felt the same way as you until I finally took the plunge recently. The water's warm, I think you'll like it too.
The biggest advantage to using tikz
is being able to make a fancier answer box easily, for example, the line:
\tikz \draw[fill=green!5] (0,0) rectangle (\linewidth, -1in) node[pos=.1]{Answer Here:};
Gives you a 5% green fill and a label:
The draw option [fill=green!5]
fills the path with 5% green, and node[pos=.1]{Answer Here:}
makes a node (tikz
's awesome placement tool) 10% of the way into the box (it measures diagonally, pos=1
would set the text at the bottom right corner).
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\noindent\\
\tikz \draw[fill=green!5] (0,0) rectangle (\linewidth, -1in) node[pos=.1]{Answer Here:};
\end{document}