5

I'd like plain TeX (pdftex) to put a specific sequence of characters between every paragraph of its output.

For example: Original text might be:

 This is paragraph 1.

 This is paragraph 2.

 This is paragraph 3.

and with the fix I'm seeking it would become:

 This is paragraph 1.

 zqx3

 This is paragraph 2.

 zqx3

 This is paragraph 3.

This is acceptable as well:

 This is paragraph 1. zqx3 This is paragraph 2. zqx3 This is paragraph 3.

I'm hoping I can set some \parxxxxx parameter to do this, akin to a header line or footerline. I'm looking for the least intrusive method. If there is an extra zqx3 before the first paragraph or after the last one, that is completely fine.

Thank you!

7

The Plain TeX token list variable \everypar will be inserted at the start of every new paragraph.

\everypar={zqx3\ }

This is paragraph 1.

This is paragraph 2.

This is paragraph 3.

\bye

Which is the same as

zqx3 This is paragraph 1.

zqx3 This is paragraph 2.

zqx3 This is paragraph 3.

\bye

Although this doesn't put the contents in a new paragraph, it might do what you want. If you need to include a new paragraph in the output, the obvious thing \everypar={zqx3\par} won't work - you'll get an infinite loop. So you'll need some logic to catch the recursion, or maybe use something other than \par that fakes a paragraph break (break the line and add a \vskip).

  • 2
    Maybe "\everypar={\vadjust{\hbox{zqx}}}" – morbusg Oct 4 '15 at 6:36
  • ^ yes that's another way - a good way IMO. OP wasn't clear whether these were required to be in a separate paragraph (with \parskip, \parindent, etc) or whether code was wanted to do something formatty. I am guessing the latter, in which case a paragraph probably isn't required, and \vadjust is a good way of inserting \skips, \hrules etc into the page. – Andrew Kepert Oct 4 '15 at 9:15
  • This answer accomplished exactly what I needed. Many thanks! – Iron Pillow Oct 5 '15 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.