0

次のように、ドキュメント内で新しいコマンドを定義しました。

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

私のテストデータは次のとおりです。

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

これにより、次の 2 つの問題が発生します。

2 番目のテスト ケースでは、必要に応じてドキュメントをフォーマットしますが、次のエラーが発生します。

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

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

ここでのコーディングの何が問題になっていますか?

さらに、2 番目のテスト ケース (のみ) を使用し、それをテスト ケース 1 と同じになるように変更すると、パラメーターが存在するにもかかわらず、このエラーが続きます。エラーが続く原因は何ですか?

4

1 に答える 1

1

\leavevmodeの後に挿入#1:

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

\\*空行の後に使用すると機能しません。

于 2010-09-23T09:33:02.570 に答える