由于参数不存在而引起的 Latex 错误
我在文档中定义了新命令,如下所示:
%---------------------------------------------------------
\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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
#1
之后插入\leavevmode
:如果在空行之后使用
\\*
,则不起作用。Insert
\leavevmode
after#1
:\\*
does not work if it is used after empty line.