views:

20

answers:

1

I have defined new commands within a document as follows:

%---------------------------------------------------------
\newcommand{\thetmpone}{}
\newcommand{\thetmptwo}{}
\newcommand{\tmpone}[1]{\renewcommand{\thetmpone}{#1}}
\newcommand{\tmptwo}[1]{\renewcommand{\thetmptwo}{#1}}
%---------------------------------------------------------
\newcommand{\datatype}[2]{#2% Data type.  Parameters are name, and a datatype attribute block.
  #1\\* is \thetmpone\par %
  \thetmptwo\par}%
%---------------------------------------------------------
\newcommand{\arbitarydtab}[0]{% Data type attribute block (dtab) for arbitary.
  \tmpone{arbitary.} %
  \tmptwo{Used for identifiers that have no intrinsic meaning.}}%
%---------------------------------------------------------

My test data is:

\datatype{test arbitary}{\arbitarydtab}
\datatype{}{\arbitarydtab}

This gives rise to two problems:

the second test case formats the document as desired but gives rise to the following error:

! LaTeX Error: There's no line here to end.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.

What is wrong with my coding here?

In addition if I use the second test case (only), then change it to be the same as test case one, this error continues, even though the parameter is now there. What is causing the persistence of the error?

+1  A: 

Insert \leavevmode after #1:

%--------------------------------------------------------- 
\newcommand{\datatype}[2]{#2% Data type.  Parameters are name, and a datatype attribute block. 
  #1\leavevmode\\* is \thetmpone\par % 
  \thetmptwo\par}% 
%--------------------------------------------------------- 

\\* does not work if it is used after empty line.

Alexey Malistov