I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
|
|
||||
|
|
The short answer is what others have said, The longer answer is that as TeX parses its input, it reads the input file line by line. It strips off tailing whitespace (including any carriage return and newline) and then appends a character corresponding to the number in the Unless the category codes have been changed (e.g., by the So what does this have to do with This can frequently be important when playing around with category codes of The long answer is contained in Chapter 8 of The TeXbook. One final use that no one has mentioned is that it is sometimes necessary for the line to end with a space character and not a end of line character. One example is that a backslash followed by a space is different than a backslash followed by a newline:
In the first line, there's a space following the
That is,
That is, |
|||||||||||||||||||
|
|
A percent sign, %, allows to end a line without generating a space character -- very useful when writing macros. |
|||
|
|
|
When I was starting out with TeX, I have read many times that the percent sign "swallows" all the whitespace after it. Whitespace includes spaces, tabs, and linebreaks. |
||||
|
|
You already got lots of answers. You can also just experiment yourself:
Try compiling this with and without the |
||||
|
|