TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a command that will take in one argument and create a rectangle around that number of empty lines. I have the following:


It only creates one line though. How can I use the #1 in here?

share|improve this question
up vote 10 down vote accepted

\framebox is a horizontal box, so you cannot add vertical space to it, without using a vertical box like \parbox inside. Here is another solution with an invisible rule:




And if you don't want the box to break the line width, you may use, e.g.

  \framebox[\dimexpr \linewidth-2\fboxrule-2\fboxsep\relax]{%

To not forget the answer to your question: You may use the #1 as a prefix of \baselineskip because \baselineskip is a length and lengths may be used like units.

share|improve this answer
+1 for the alternative. I was doing all sort of weird stuff with forloops and whatnot. – recluze Nov 5 '11 at 12:14

If you want to get fancier, you could also use something like mdframed, or tikz.

Here is a tikz solution using shadedbox from How to right align a table in a tikz picture, so if you like this solution, please up vote that answer.

The \putansbox defined here accept an optional first parameter that provides you the option of using the full power of tikz to modify what you want. Refer to the TikZ documentation for more details and options, but the options that are shown in this MWE include:

  • specify a top/bottom color for the shading: bottom color=yellow!10, top color=red!10
  • using rounded corners: rounded corners=15pt
  • adjusting the line width: line width=1pt
  • adjusting the line color: draw=blue
  • adjusting the width of the box: text width=0.6\linewidth
  • adjusting the line style: densely dotted

See the TikZ documentation for more options.

enter image description here


\tikzstyle{shadedbox} = [
  text width=0.97\linewidth,
  shade, top color=white, bottom color=white,
  drop shadow={
    top color=black,
    bottom color=black,
    shadow xshift=2pt,
    shadow yshift=-2pt,

    \node [shadedbox, #1] (box) {%
    \vspace {#2\baselineskip}%



\putansbox[bottom color=yellow!10]{5}

\putansbox[rounded corners=15pt, line width=1pt, draw=blue]{5}

\putansbox[text width=0.6\linewidth, top color=red!10, densely dotted]{5}
share|improve this answer
Thanks ... I guess this is a little over my head and also a little bit of an overkill. I'm designing this for print and want to keep it simple. Good intro to tikz though. – recluze Nov 6 '11 at 10:05

Here a solution based on \phantombox{<width>}{<height>}{<depth>} from my adjustbox package. It creates an empty box with the given dimensions, then use \frame to draw a tight frame around it. I also added some other macros to add some separation between the surrounding text.






share|improve this answer

Your Answer


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.