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?

3 Answers 3


\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.

  • +1 for the alternative. I was doing all sort of weird stuff with forloops and whatnot.
    – recluze
    Nov 5, 2011 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}
  • 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, 2011 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.







You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .