Generalref of theorem and lemma

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
pallav
Posts: 170
Joined: Wed Nov 12, 2008 5:53 pm

ref of theorem and lemma

Post by pallav »

Please see the following code containing a theorem and a lemma labeled as \label{theo1} and \label{lem1} respectively

Code: Select all

From Theorem \ref{theo1} and Lemma \ref{lem1} we get.......
We will get the outpot as
From Theorem 1.1 and Lemma 1.2 we get.......
I want to get the same output without writing the words theorem and lemma in the code, that is by writing

Code: Select all

From  \ref{theo1} and  \ref{lem1} we get.......
is it possible to get the output as
From Theorem 1.1 and Lemma 1.2 we get.......
plz suggest.

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ref of theorem and lemma

Post by localghost »

I guess that either the cleveref package or the \autoref command from hyperref should do.


Thorsten
pallav
Posts: 170
Joined: Wed Nov 12, 2008 5:53 pm

ref of theorem and lemma

Post by pallav »

Code: Select all

\documentclass[12pt]{article}
\usepackage{psfrag}
\usepackage[parfill]{parskip}
\usepackage{float, graphicx}
\usepackage[]{epsfig}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{verbatim}
\usepackage{multicol}
\usepackage{url}
\usepackage{latexsym}
 \usepackage{mathrsfs}
\usepackage[colorlinks, bookmarks=true]{hyperref}
\usepackage{autoref}
\usepackage{easybmat}
\usepackage{amsmath}
\usepackage{subfigure}
\allowdisplaybreaks[1]
\hypersetup{colorlinks = true,linkcolor = blue, anchorcolor = blue, citecolor = blue, filecolor = red,urlcolor = red}
\usepackage{hypcap}
\topmargin -0.6in \textwidth  6.5in \textheight 9in
\addtolength{\oddsidemargin}{-0.55in}
\numberwithin{equation}{section}%\begin{document}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{proposition}[theorem]{Proposition}
\newenvironment{proof}[1][Proof]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{example}[1][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newtheorem{corollary}[theorem]{Corollary}
\def\h{\hspace{0.25cm}}
\def\sh{\hspace{0.1cm}}
\begin{document}
\begin{theorem}\label{Th_1}
This is my theorem
\end{theorem}
\begin{lemma}\label{Le_1}
This is my lemma
\end{lemma}
\begin{eqnarray} \label{Eqn_1}
a+b=c
\end{eqnarray}
From \ref{Th_1}, \ref{Le_1} and \ref{Eqn_1} we get.... \\
\end{document}
I want to get the output of the line

Code: Select all

From \ref{Th_1}, \ref{Le_1} and \ref{Eqn_1} we get....
as
From Theorem 1.1 , Lemma 1.2 and Eq. 1.1 we get....
Similarly if I include fig. then I want to get output after referring Fig as
Fig. 1.
Please help me indetails. I have included here \usepackage{autoref} but unable to get my needs.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

ref of theorem and lemma

Post by localghost »

I don't see where the talk was of a package called »autoref«. Please read the manuals of the suggested packages. Build a minimal working example (MWE) that shows the problems clearly (the emphasize is on minimal).
Post Reply