这只是一个小片段,用于调试:
\documentclass[12pt]{article}
\usepackage{amsmath}
\def\block#1{\begin{array}{ll}\ &{#1}\end{array}}
\def\sub#1#2{\text{#1}:\\\block{#2}}
\begin{document}
$\sub{If $A$}{\sub{If $B$}{...} \\ \sub{If $\lnot B$}{...}} \\ \sub{If $\neg A$}{...}$
\end{document}
当我尝试运行latex
此程序时,我得到:
% latex debug.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex)
restricted \write18 enabled.
entering extended mode
(./debug.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (./debug.aux)
! Missing } inserted.
<inserted text>
}
l.11 ...b{If $B$}{...} \\ \sub{If $\lnot B$}{...}}
\\ \sub{If $\neg A$}{...}
? x
No pages of output.
Transcript written on debug.log.
源代码中有什么错误?
编辑:结果应该如下所示:
答案1
\def
不应在 latex 文档中使用,而且很难猜测这里的意图,因为您没有给出所需输出的指示,但括号中的括号{#1}
没有任何用处,并且会产生错误,如您所见。如果将它们删除,您将得到
\documentclass[12pt]{article}
\usepackage{amsmath}
\def\block#1{\begin{array}{ll}\ \end{array}}
\def\sub#1#2{\text{#1}:\\\block{#2}}
\begin{document}
$\sub{If $A$}{\sub{If $B$}{...} \\ \sub{If $\lnot B$}{...}} \\ \sub{If $\neg A$}{...}$
\end{document}