Of course, you can use comments to do this:
However, a lot of people don't like the look of that. Some of the responders on StackOverflow gave some alternatives that seemed ugly and half baked. So I came up with \gobblepars, which is a macro you can add to the end of your own macro definitions to cause them to eat up all trailing pars, or you can use explicitly. For example:\somemacro{} % Some text
would do the same as the commented stuff above. Moreover, if you had control over \somemacro, you could build \gobblepars into it (in fact, even if you didn't have control, you could use \let and \def to augment an existing macro with a trailing \gobblepars, but that's a different topic).\somemacro{}\gobblepars Some text
Here's the simple definition of \globblepars (you put this in the preamble of your LaTeX document):
So that's pretty simple. It checks for a \par (which includes a blank line in the source) trailing it. If it finds one, it gobbles it up (i.e., gets rid of it) and then calls itself again. This process will continue until it finds something other than a \par. Hence, it "gobbles" strings of "pars".\makeatletter \newcommand\gobblepars{% \@ifnextchar\par% {\expandafter\gobblepars\@gobble}% {}} \makeatother
No comments:
Post a Comment