I am correcting an article I wrote based on the reviews of my referees. What I want to do is to create a document that unifies both the text of the article (written in tex) and the corrections. Since in the corrections I need to quote verbatim parts of the article, I wondered if there is a smart way to do it. If I had full control of the document (which I don't, since the document is shared with collaborators) I would put the sections I modified in a separate .tex file and include them in the text and in the corrections where I need to show what I modified as a standalone comment. In this way, I can modify the .tex file of the section every time I want and both the article and the corrections would be updated. However, this is not possible, so I was wondering if there is a way to enclose some part of the text in some environment or just to call it with a label and then refer to the label/environment and clone the entire section to another place of the document. Something similar to the \snippet tool of Doxygen to be clear.


% Part one: corrections
Here I review what I did in the in the first part and I quote [snippet_one]

Here I review the second part of the text and I quote [snippet_two]
% Part two: Full article

Some text with also formulas
Text text 
Some more text
Some other text with other formulas

  • You could put everything you wanted to clone inside a \newcommand{\someselection}{...}, then call it immediately afterwards in the body, and then again in the comments, but that's not a very elegant solution, so maybe someone else has a better idea.
    – frabjous
    Commented Apr 2, 2022 at 18:39

1 Answer 1


I'm using the scontents package for this. Enclose the part that you want to be able to repeat inside a scontents environment, and then recall it with \getstored.

text that you want to repeat


a_name is a name of your choice.

  • +1: Never heard of the scontents package, seems useful! Commented Apr 3, 2022 at 3:39
  • 2
    I found out about scontents a couple of years ago when I was looking for a way to create single exercise files that would contain, on one page, only the questions and, on another page, the questions and the answers. It's very robust, and I combine it with a small macro that reset counters, so that figure numbering is identical in both versions of the questions.
    – Miyase
    Commented Apr 3, 2022 at 5:39
  • This worked almost perfectly, thanks! The only flaw I'm finding is that I can to call \getstored{a_name} only after I defined a_env and while not crucial, it's a pity. I hope there is an easy fix, but scontents just entered my list of packages to stay. (Also, you gave me a good tip for exercises sheets)
    – Kimala
    Commented Apr 3, 2022 at 17:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .