由于参数不存在而引起的 Latex 错误

发布于 2024-09-24 09:46:30 字数 1192 浏览 2 评论 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}

这会产生两个问题:

第二个测试用例根据需要格式化文档,但会产生以下错误:

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

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

我在这里的编码有什么问题吗?

此外,如果我(仅)使用第二个测试用例,然后将其更改为与测试用例一相同,则即使参数现在存在,此错误仍然存​​在。是什么导致错误持续存在?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

策马西风 2024-10-01 09:46:30

#1之后插入\leavevmode

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

如果在空行之后使用\\*,则不起作用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文