[Tex/LaTex] copy and reuse the content of an environment

content-replicationcopy/pasteenvironments

is there a way to embed an text in several environments (or structures, \chapter, \section etc.) in one file and "copy"/insert the content of single environment items in other files? i've noticed the clipboard and extract packages and had the thought about \def and \newcommand. but those aren't satisfying, mostly because it seems unaesthetic to me; I just want ordinary environments.

The extract package just places the content into a new file, which is what I seek to avoid. Consider an huge collection of aphorisms, quotes or equations (and others, so the solution should be abstract enough to handle different content, I guess environments would fit well). I just don't want a file for each single item, it would be far too many.

So something like "I want to use the environment x, this x shall be named x1, that x2 the other x3", as I would do with the extract package would be pleasant, just I need now access to these x1, x2 and x3 instead of a file. Something like "here I want to place a copy of x1, there of x2, here of x1 again, there of x3".

So as example I want something like:

quotesFile.tex:

\begin{myquote} % any environment
\contentName{quote1} % define some kind of identifier 
                     % for this environments content
This is a quote
\end{myquote}

\begin{myquote}
\contentName{quote2}
lorem ipsum dolor sit amet
\end{myquote}

\begin{myquote}
\contentName{quote3}
foo bar baz foobar foobaz
\end{myquote}

and in otherfile.tex:
\include{quotesFile}

\placeContent{quote2} % I want something as simple 
                      % as this to insert the content 
                      % of the environment, here with 
                      % the identifier "quote2"

\placeContent{quote3} 

so the output should be:
lorem ipsum dolor sit amet

foo bar baz foobar foobaz

I do not want something like

\newcommand{\quote1}[]{This is a quote}

for several reasons. Well, it kinda would solve the problem but it just doesn't seem aesthetical to me (blame me). I prefer to keep things clear and tidy and all the brackets and commands which are actually just simple text don't seem tidy to me but rather confusing. According to my opinion and understanding commands/macros shall serve to avoid repetition of code but aren't to be used for ordinary text content.

Best Answer

The package to use in this case is:

http://www.ctan.org/tex-archive/macros/latex/contrib/catchfilebetweentags/ gives the clearest code for this type of system of documents, each one citing perhaps parts of other.

Basically, a system of organization based on placing tags with some kind indexing convention (in between which a particular environment with a often reused piece of code or text goes) in documents allows using pieces of each as necessary where these may be littered and reused across many documents.

If the indexing convention is clever (use different prime numbers multiplied together to uniquely mark across documents as often done in software, as suggested by the only scientist recognized by posterity for his efforts with a brand of biscuits named after him?) or straightforward, say [Lichtenberg]{B-25},for the 25th aphorism of Lichtenberg's journal B, found in a larger document (a quotes file Lichtenberg, itself broken into sections A, B, C, according to the journals that sources of the quote in this case.

Related Question