4

I am working on a script and I would like to put some proofs in an extra section. But, for editing, I would like to place the proof right after the proposition. So, I would like some kind of command that sends the input in a predefined section (For example: appends the input to the end of the section)

I have in mind something like this:

This code

\section{section}
Hello
\sendtoOtherSection{World}

\section{other section} Nothing here

produces:

1 section

Hello

2 other section

Nothing here

World

Like the title of this question says, I don't care if \sendtoOtherSection is a command or environment. It is not very important in which order the shifted text appears.

bitt.j
  • 613

1 Answers1

4

Since you want to just move the text forward, you could adapt the answer from How keep a running list of strings and then process them one at a time to keep building up these sections that need to appear later. Then when you want them to appear you just make a call to \OtherSection, and the code accumulated is typeset there:

enter image description here

\documentclass{article}

\def\OtherSection{}
\makeatletter
\newcommand{\sendtoOtherSection}[1]{%
    \g@addto@macro\OtherSection{{#1}\par\noindent}%
}
\makeatother

\begin{document}
\section{Section One}
\par\noindent
Hello. Hello.
\sendtoOtherSection{Is there anybody out there?}

\section{Section Two}
Goodbye Cruel World.
\sendtoOtherSection{I'm leaving you today.}

\section{Other Section}
\OtherSection
\end{document}
Peter Grill
  • 223,288