Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Will the "other section" always be after the "section"? (Because well, moving some data forward is much easier than backward.) –  tohecz Mar 20 '12 at 22:04
1  
Have a look at a-theorem-and-its-proof-in-different-places/45332#45332 and see it helps- on first glance, I think it's a duplicate, if not, please say so –  cmhughes Mar 20 '12 at 22:16
    
@cmhughes Thank you. This was quite helpful. So my question is a duplicate but I think the given answer is new (Peter Grill). –  bitt.j Mar 21 '12 at 18:10

1 Answer 1

up vote 4 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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