[Tex/LaTex] Error: paragraph ended before … was complete


I'm quite lost. I can't figure out what I'm doing wrong below.



  \typeout{=======> \space\space ae@rmb}%%

  \typeout{=======> \space @ae@rmb}%%

  \typeout{=======> @@ae@rmb}%%
  {\typeout{\space\space\space optional arg}\@@@ae@rmb}
  {\typeout{no optional arg}\@@@ae@rmb[\depth]}}


%% \def\@@@ae@rmb[#1]#2{%%
%%   \typeout{-->\detokenize\x{\ae@i@r}}%%
%%   \typeout{-->\detokenize\x{\ae@i@ht}}%%
%%   \typeout{==>\detokenize{#1}}}%%
%%   \raisebox{\ae@i@r}[\ae@i@ht][#1]{\mbox{$#2$}}}




I get the following error with the above code:

=======>   ae@rmb
=======>  @ae@rmb
=======> @@ae@rmb
no optional arg
Runaway argument?
! Paragraph ended before \@@@ae@rmb was complete.
<to be read again> 


Best Answer

Let's see what happens.




The macro \ae@rmb tests if the next token is [, skipping spaces. The next token is \par, due to the empty line. Thus the input stream, at this point, is


and now it becomes


The macro \@ae@rmb does \def\ae@i@ht{\height} and the input stream becomes


Since the next token is not [, this becomes


and now you have the problem, because argument #2 to \@@@ae@rmb is \par; this is illegal because the macro is not long. But making it \long is not the solution, because $\par$ is illegal either.

Probably you should define

  something with the saved height,
  with #1 which is the desired depth
  and with \ae@i@r

An easier implementation with xparse:


  arg: $#3$




Of course you'll have better ideas about what to do with the arguments.

enter image description here

Related Question