这是我的 MWE:
\documentclass{article}
\setlength{\parindent}{0pt}
\setlength{\parskip}{3pt}
\begin{document}
Here is the first paragraph.
Here is the second.
\newcommand*{\testing}[1]{#1}
\testing{\par Here is the third.\par Here is the fourth.}
\end{document}
在这种情况下,输出看起来正确:
但是,我遇到了编译器错误:
Runaway argument?
! Paragraph ended before \testing was complete
我尝试过使用\\\\
而不是\par
,但是它会在段落之间产生不正确的间距。
如何在命令参数中定义多个段落并使其格式化,就像我直接输入这些段落一样?
答案1
命令\newcommand*{\testing}[1]{#1}
(带星号的版本!)根本不允许\par
在代码中使用#1
。
如果您需要\par
使用命令\newcommand{\testing}[1]{#1}
(无星号),则它被定义为允许\par
...
查看更正后的代码
\documentclass{article}
\setlength{\parindent}{0pt}
\setlength{\parskip}{3pt}
\begin{document}
Here is the first paragraph.
Here is the second.
\newcommand{\testing}[1]{#1} % <======================================== no star
\testing{\par Here is the third.\par Here is the fourth.}
\end{document}
并且其编译结果没有错误: