# Why can't I insert a blank line in this code?

In the code below, everything is OK until I insert a blank line instead of one of the \\'s. Upon inserting a blank line, I'll get some errors. How can I get rid of these errors?

\documentclass{article}
\newsavebox\mybox
\newcommand{\Class}[1]
{
\sbox{\mybox}{\begin{tabular}{l}#1\end{tabular}}
\fbox{\parbox{\wd\mybox}{\texttt{#1}}}
}
\begin{document}
\Class
{double Width\\
double Height\\
double Perimeter\\
double Area\\
}

\usebox\mybox
\end{document}

Edit:
My indented output is:

-
@Qrrbrbirlbel Any solutions which do the trick is appreciated. –  Vahid Damanafshan Feb 14 '13 at 22:01
What do you intend this code to do, it s very weird, why are you setting # twice in both a tabular and a parbox? Surely it makes more sense just to put the \fbox` around the tabular? –  David Carlisle Feb 14 '13 at 22:04
@DavidCarlisle Please see my update. I added a screenshot. –  Vahid Damanafshan Feb 14 '13 at 22:13
"indented" or "intended"? –  I am who I say I am Feb 15 '13 at 0:22

The command \texttt does not allow paragraph breaks in its argument. You could use \ttfamily instead but a blank line inside a tabular doesn't do anything useful, so it is probably better to have the error message to warn of the incorrect input.

Perhaps this which makes a blank line do \\ ?

\documentclass{article}
\newsavebox\mybox
\usepackage{array}
\newcommand{\Class}[1]
{%
\sbox{\mybox}{\begin{tabular}{>{\expandafter\def\csname par\endcsname{\\}}l}#1\end{tabular}}%
\fbox{\parbox{\wd\mybox}{\par{\def\par{\\}\ttfamily{#1}}}}%
}
\begin{document}
\Class
{double Width\\
double Height

double Perimeter\\
double Area\\
}

\usebox\mybox
\end{document}
-
So could you please provide me with another solution instead of the tabular environment which give me the same output? –  Vahid Damanafshan Feb 14 '13 at 22:07
I could if I could guess what you want a blank line to do? As I say if you change \texttt to \ttfamily it works without error but perhaps isn't the output you want –  David Carlisle Feb 14 '13 at 22:19
As for the output, You are completely right. If I change \texttt to \ttfamily, it works without errors, but the width of the frame, becomes bigger. –  Vahid Damanafshan Feb 14 '13 at 22:27
@DavaidCarlisle your solution works, but could you please tell me why after inserting \Class {double Width\ double Height ‎bla‎ ‎bla‎‎ ‎bla‎‎ double Perimeter ‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎\\ double Area\}, the third bla falls in the next line in spite of the enough space? –  Vahid Damanafshan Feb 14 '13 at 22:50

You can simply \fbox the tabular and use \\ for blank lines; to get typewriter type use \ttfamily; the \fbox keeps the font change local.

\documentclass{article}

\newcommand{\Class}[1]{%
\fbox{\ttfamily\begin{tabular}{l}#1\end{tabular}}%
}

\begin{document}
\Class
{double Width\\
double Height\\
\\
double Perimeter\\
double Area\\
}

\end{document}

Beware of spurious spaces and comment end of lines in definitions.

-