As the title said, I want to make some texts (at least 2 paragraphs) labeled (or any way like that), and then, I need to exactly "reproduce" (for now I use \ref) its appearance in the first document onto another document. Hopefully I say it clear.
This is what I expect finally:
I currently have an imperfect solution, which can label ONE paragraph but encounter mistakes when dealing with 2 or more paragraphs. Here is the MWE:
%%%% test.tex
\documentclass[onecolumn]{article} %
\usepackage{color}
\makeatletter
\newcommand{\labeltext}[1]{%
#1%
\protected@edef\@currentlabel{#1}%
}
\makeatother
\begin{document}
\section{Introduction}
\labeltext{Optimization, in general, is concerned with finding the best solutions for a given problem.
Since the real world problems are endlessly emerging with the development of science and technology, the universal domain is keeping inflating. } \label{aaa}
\end{document}
%%%% main.tex
\documentclass[onecolumn]{article} %
\usepackage{color}
\usepackage{xr}
\externaldocument{test}
\begin{document}
That is from another doc: ``\color{red}{\ref{aaa}}''.
\end{document}
Someone also give me the this, which did label many paragraphs, but can only be used in the same ONE document. I put it here in case anyone wants to refer.
\documentclass[onecolumn]{article} %
\usepackage{color}
\makeatletter
\newcommand{\labeltext}[2]{%
#1%
\expandafter\edef\csname#2\endcsname{#1}%
}
\makeatother
\begin{document}
\section{Introduction}
\labeltext{Optimization, in general, is concerned with finding the best solutions for a given problem.
Since the real world problems are endlessly emerging with the development of science and technology, the universal domain is keeping inflating. }{aaa}
\end{document}
And I did notice there are some similar questions here, but I didn't see my target. This is an example, which also only work for cross doc ref of ONE paragraph.
Labeling a text and referencing it later