I have sought long and hard for a solution to this and experimented with a combination of https://tex.stackexchange.com/a/43351 and https://tex.stackexchange.com/a/443, but could not get it to work. I would like the following to happen:
I define an example somewhere in the text like this
\begin{shortex}\label{Example1} lorem ipsum \end{shortex}Later in the document, I introduce an altered version of the example (Example 1'), if possible using
cleveref
Here's my code before any of that happens:
\documentclass[letterpaper,12pt]{article}
%Math symbol packages
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%Add several formatting packages
\usepackage{paralist}
\usepackage[colorlinks=true,hidelinks]{hyperref}
\usepackage{cleveref}
\crefdefaultlabelformat{[#2#1#3]}
%Add theorem support
\usepackage{amsthm}
%Define example
\theoremstyle{definition}
\newtheorem{ex}{Example}
\renewcommand{\theex}{\arabic{ex}}
%Access package-internal code that uses @
\makeatletter
% Define examples without linebreaks
\newenvironment{shortex}
{\refstepcounter{ex}\textsc{Example~}\theex:\normalfont}%\begin{shortex}
{}%\end{shortex}
\makeatother
%Define cref for Examples
\crefname{ex}{}{examples}
\creflabelformat{ex}{(#2#1#3)}
\begin{document}
\begin{shortex}\label{ex1} This is example 1 \end{shortex}
\end{document}
I have tried getting rid of shortex and simply using {ex}, but this still wouldn't work.
Thanks for any help y'all can give!
EDIT (djupp): I also found David Carlisle's https://tex.stackexchange.com/a/69918/27148 now, which would probably work great if I could incorporate the suggested use of \ref (or \cref) to refer back to an older example. (I.e., it's possible that I would want to restate example 1 after I've already stated 2,3,4,5,etc.)
