As stated elsewhere, it is usually quite recommended to use the starred \newcommand* instead of \newcommand since this helps finding missing }s by disallowing paragraphs in its argument. Every now and then, it is however desired to let such a command, e.g. \pdfmarkupcomment, act on (parts of) multiple paragraphs+. Is there any way to define an environment (say, pdfmarkedup, or can the environment share the command's name?) such that it automatically wraps each paragraph into the desired single-paragraph command? I.e.
\documentclass{article}
\usepackage{pdfcomment}
\newenvironment{pdfmarkedup}{%
% insert magic here
}
\begin{document}
\begin{pdfmarkedup}[markup=Highlight]{no comment}
I'm a little paragraph short and stout.
Here is my last stop.
Here is my successor.
When I get all wrapped up,
Hear me shout!
Just write me down
and pour me out.
I'm a clever environment, yes it's true.
Here's an example of what I can do.
I can wrap my paragraphs each into a command.
Just put me around them and pour me out.
\end{pdfmarkedup}
\end{document}
should be equivalent to
\documentclass{article}
\usepackage{pdfcomment}
\begin{document}
\pdfmarkupcomment[markup=Highlight]{
I'm a little paragraph short and stout.
Here is my last stop.
}{No comment}
\pdfmarkupcomment[markup=Highlight]{
Here is my successor.
When I get all wrapped up,
Hear me shout!
}{No comment}
\pdfmarkupcomment[markup=Highlight]{
Just write me down
and pour me out.
}{No comment}
\pdfmarkupcomment[markup=Highlight]{
I'm a clever environment, yes it's true.
Here's an example of what I can do.
I can wrap my paragraphs each into a command.
Just put me around them and pour me out.
}{No comment}
\end{document}
+ In my example of \pdfmarkupcomment, it would be acceptable to have the same comment repeated over each paragraph.
\documentclass{article}\usepackage{pdfcomment}\begin{document}and\end{document}wrapped around it, the first form obviously needs the sought environment's definition in addition. Probably some iteration over the paragraphs inside...Butpdfmarkupcommentis really just an example, this might as well be any other star-defined macro, e.g.\newcommand*{\red}[#1]{{\color{red}#1}}– Tobias Kienzler Dec 09 '15 at 07:55\colorexample) I can think of no cases where the complexity of doing this do not outweigh the benefits of the*form so simply using\newcommandwould be preferable, But if you have and existing command that only works on text runs it could be done, probably although the details would depend on the command – David Carlisle Dec 09 '15 at 08:03environpackage? – egreg Dec 09 '15 at 08:06\begin{pdfmarkedup}a\par b\par c\end{pdfmarkedup}to be equivalent to\pdfmarkupcomment{a}\par\pdfmarkupcomment{b}\par\pdfmarkupcomment{c}? – egreg Dec 09 '15 at 08:20\paras\egroup\bgroup\fooso the command stops and starts at each blank line., Other commands really need explicit{}so there you would have to scan over the text splitting at\parand adding\foo{...}which is more general but more complicated, but as egreg's shown that I'll leave him to get the tick:-) – David Carlisle Dec 09 '15 at 09:00