[Tex/LaTex] How to display the same text in various parts of the document

cross-referencingquoting

In a long, long, long writing. I have a piece of text that repeats in several places/sections/chapters. When I'm editing, I change 2 or 3 words in that piece of text. The changes have to be applied to all its repetitions in the document. The question is, how can I automate this?

The solution I'm looking for would be something like:

Lorem ipsum \textthatrepeatselsehwhere{This text will be shown in several places}\label{textrep1} lorem ipsum.

Lorem ipsum \displaytextoflabel{textrep1} lorem lorem.

The output should look like:

Lorem ipsum This text will be shown in several places lorem ipsum.

Lorem ipsum This text will be shown in several places lorem lorem.

The solution might be obvious but I don't know how to do it. Thanks, any help will be appreciated.

Best Answer

You can define a macro for this job.

\newcommand\mytext{This text will be shown in several places\xspace}

A MWE:

\documentclass{article}
\usepackage{xspace}
\newcommand\mytext{This text will be shown in several places\xspace}
\begin{document}
Lorem ipsum \mytext lorem ipsum.

Lorem ipsum \mytext lorem lorem \mytext.

\end{document}

enter image description here