Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[14pt]{article}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\begin{document}
\section{Sample}

\begin{thm}\label{mmm} 
qwerty
\end{thm}

\begin{defn}
\label{ppp} 
qwerty
\end{defn}

Theorem \ref{mmm}

\end{document}
  1. When implementing this code into LaTeX, my theorem and definition comes out as Theorem 1.1. and Definition 1.2. How can I remove the . at the end? So it would come out as Theorem 1.1 and Definition 1.2?

  2. Theorem \ref{mmm} would correctly as Theorem 1.1, but is there a way that would enable me to not have the need to type Theorem before the \ref{mmm}? I.E. I don't need to type theorem every time I want to reference to a theorem.

share|improve this question
2  
For the second question: Define your own command something like \newcommand{\thmref}[1]{Theorem~\ref{#1}} in the preamble of your document. Use as \thmref{mmm_tasty_theorem} –  percusse Dec 7 '11 at 4:08
    
thanks, is that a standard thing to do in a thesis or do people just type out theorem? –  Thomas Dec 7 '11 at 4:12
1  
Well, they are simply equivalent so I can't see how it can make a difference in a thesis context. (I wrote two theses with it) Maybe I don't get your question properly. –  percusse Dec 7 '11 at 4:14
    
Thanks, its ok, you've answered my question. –  Thomas Dec 7 '11 at 4:19
1  
@David: cleveref defines \crefname and \Crefname so you can use \cref and \Cref in order to capitalize the first letter of the object. In my answer I only defined \crefname since typically one would use Theorem ?? regardless of whether it follows a period (end-of-sentence) or not. –  Werner Dec 7 '11 at 7:28

1 Answer 1

up vote 8 down vote accepted

In answer to your first question, this is the default behaviour for the plain theorem style in amsthm. In order to remove this, define your own theorem style, say mytheorem using \newtheoremstyle:

enter image description here

\documentclass{article}
\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\newtheoremstyle{mytheorem}% <name>
  {\topsep}% <space above>
  {\topsep}% <space below>
  {\itshape}% <body font>
  {}% <indent amount>
  {\bfseries}% <theorem head font>
  {}% <punctuation after theorem head>
  {.5em}% <space after theorem head>
  {}% <theorem head spec>
\theoremstyle{mytheorem}% choose style
\newtheorem{thm}{Theorem}[section]
\newtheorem{defn}[thm]{Definition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\begin{document}
\section{Sample}

\begin{thm}\label{mmm} 
qwerty
\end{thm}

\begin{defn}
\label{ppp} 
qwerty
\end{defn}

Theorem \ref{mmm}

\end{document}

The punctuation is given as the seventh parameter to \newtheoremstyle. For the (default) plain style, this is .. Also, plain has \topsep as the "above" and "below" space.


In answer to your second question, the cleveref package provides an easy work-around. You define the reference name associated with that particular reference using \crefname{<style>}{<singular>}{<plural>}, where <style> is your defined theorem thm:

enter image description here

\documentclass{article}
\usepackage{cleveref}% http://ctan.org/pkg/cleveref
\usepackage{amsthm}% http://ctan.org/pkg/amsthm
\newtheoremstyle{mytheorem}% <name>
  {\topsep}% <space above>
  {\topsep}% <space below>
  {\itshape}% <body font>
  {}% <indent amount>
  {\bfseries}% <theorem head font>
  {}% <punctuation after theorem head>
  {.5em}% <space after theorem head>
  {}% <theorem head spec>
\theoremstyle{mytheorem}% choose style
\newtheorem{thm}{Theorem}[section] \crefname{thm}{Theorem}{Theorems}
\newtheorem{defn}[thm]{Definition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\begin{document}
\section{Sample}

\begin{thm}\label{mmm} 
qwerty
\end{thm}

\begin{defn}
\label{ppp} 
qwerty
\end{defn}

Theorem \ref{mmm}, or \cref{mmm}.

\end{document}

The above example combines a solution to both problems.

share|improve this answer
    
The plain style uses \topsep for "space above" and "space below". –  Gonzalo Medina Dec 7 '11 at 5:01
    
@GonzaloMedina: Thanks. It wasn't meant to be exactly duplicate, but I changed it anyways. –  Werner Dec 7 '11 at 5:10
    
Thanks so much Werner, most appreciated! –  Thomas Dec 7 '11 at 23:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.