GeneralRepeating LaTeX items (equations, descriptions, etc.)

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
swampman
Posts: 2
Joined: Mon Mar 30, 2009 9:31 pm

Repeating LaTeX items (equations, descriptions, etc.)

Post by swampman »

Hello all.

Anyone know if there is a general way of repeating labelled items in full?

It's often useful for me to give numbered examples at various points in a paper. I use the covington package, which does this sort of thing pretty well:
(1) This is an important point

blah blah blah blah

(2) This is also an important point
However, I often find it useful to refer back to examples several pages later, so would like to be able to repeat the whole example (rather than just giving the example number) like so:
(1) This is an important point

blah blah blah blah

(2) This is also an important point

blah blah blah blah
blah blah blah blah

(1) This is an important point
Is there a simple way of repeating an item, so that the repeated items reflect any changes in numbering or content that I make to the first one? It'd be pretty useful to be able to do this with any sort of item (equations, descriptions, etc) that it's possible to label.

Apologies if I've missed something obvious - I can't immediately see a way of doing this with cross-referencing and google is of little help.

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

curiouslearn
Posts: 105
Joined: Fri Nov 30, 2007 11:32 pm

Repeating LaTeX items (equations, descriptions, etc.)

Post by curiouslearn »

Perhaps there is a better way to do this. But one way to do this is to to use \def. It is not considered good to use \def, but somehow I find its use more intuitive compared to \newcommand, so I will give you an example with that. To avoid clash with latex commands, I start my commands with uppercase letters.

Code: Select all

\def\ExampleOne{This is example one. Latex is great}
Now, anywhere else in the text, you could simply use,

Code: Select all

\ExampleOne


to repeat the example.
swampman
Posts: 2
Joined: Mon Mar 30, 2009 9:31 pm

Re: Repeating LaTeX items (equations, descriptions, etc.)

Post by swampman »

Yep. Cheers.
episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

Repeating LaTeX items (equations, descriptions, etc.)

Post by episanty »

I have an answer to your question, and a question of my own:

for equations, a more elegant solution is

Code: Select all

\begin{equation}
2+2=5
\label{Orwell}
\end{equation}
followed later in the text (or even, possibly, earlier) by

Code: Select all

\begin{equation}
2+2=5
\tag{\ref{Orwell}}
\end{equation}
However, this seems to make hyperref complain that "destination with the same identifier (name.equation.Alph2.0.1)) has already been used, duplicate ignored".

does anyone know how to avoid this?
episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

Repeating LaTeX items (equations, descriptions, etc.)

Post by episanty »

now this is really bizarre. I just found a solution but I really don't understand it: changing equation environments to align stopped TeX complaining. Can anyone see why this is? I don't like it very much as a stable, general solution, but it will do...
Post Reply