webframp / sicp-info

Stucture and Interpretation of Computer Progams in info format
http://www.neilvandyke.org/sicp-texi/
113 stars 20 forks source link

Multiline macro arguments break indexing, macro expansion #12

Open thoelze1 opened 4 years ago

thoelze1 commented 4 years ago

Each time a new term is introduced, the following macro is used to add the term to the index (with @cindex) and format the term (with @dfn):

@macro newterm{term}
@cindex \term\
@dfn{\term\}
@end macro

Sometimes term happens to span multiple lines (usually due to the 80-character fill-width used in sicp.texi), which is fine because @newterm has only one argument (see the manual). However, @cindex takes its argument on a single line (see the manual) so when term spans multiple lines, @cindex adds only the first line of term to the index, and the remaining lines are simply expanded in the macro. Therefore the following source in sicp.texi (line 1388):

Such exceptions to the general evaluation rule are called @newterm{special
forms}.

Expands into:

Such exceptions to the general evaluation rule are called @cindex special
forms @dfn{special
forms}.

Which results in the following sicp.info:

  Such exceptions to the general evaluation rule are called forms
"special forms".

@newterm is used about 424 times in sicp.texi and its argument occurs on a line break about 31 times (resulting in the undesirable behavior of the index and macro expansion). I tried adjusting the @newterm macro in a few ways to collapse term into a single line, but I wasn't able (maybe someone more familiar with texinfo/tex knows a way?). Editing the 31 problematic macro invocations would certainly solve this, but would defy the 80-character fill-width.

webframp commented 4 years ago

I don't have any great suggestions for this one, but am open to ideas from someone more experienced with texinfo to me and definitely will merge improvments