开发者

Latex error arising from non-existent parameter

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}%
%---------------------------------------------------开发者_如何学Go------
\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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜