[Tex/LaTex] Latex errors with \begin{theorem}

errorstheorems

I am trying to create a new theorem in a tex document, but I keep getting an error. Here is the code I am currently using

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage{wasysym}
\usepackage{lipsum}
\usepackage{amssymb}
\usepackage{amsthm}

\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{9.5in}

\newtheorem{theorem}[Theorem]



\begin{document}

\begin{theorem}
    My Tex doesn't work
\end{theorem}


\end{document}

When I try to compile this, I get three errors.

Paragraph ended before \@ynthm was complete.

Environment theorem
undefined. \begin{theorem}

\begin{document} ended by
\end{theorem}. \end{theorem}

I am assuming the last error is a direct consequence of \begin{theorem} not being recognized, so if I can solve the first two errors, I think I will be okay.

I have tried changing \newtheorem{theorem}[Theorem] to \newtheorem{theorem}{Theorem}[Theorem] to no avail, and changed \begin{theorem} to \begin{theorem}[Theorem] again with no positive result.

Any ideas would be very helpful, thanks!

Best Answer

The syntax of \newtheorem can be confusing:

See the amsthm documentation for more detailled explanation but in short it's like this:

Use

  • \newtheorem{theorem}{Theorem} if theorem shall be the counter (it's defined then, and Theorem is the environment name.)
  • \newtheorem{theorem}{Theorem}[foo] if Theorem should be the environment name and foo is an existing counter that shall be used as the reset driver
  • \newtheorem{theorem}[foobar]{Theorem} if foobar is a different counter that already exists and should be used for counting.

In any case: \newtheorem{theoremenvironment}{Environmentname} is mandatory. This was missing in the OP.

The precise behaviour depends on the position of the optional argument (or if it is used at all ;-))


\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{enumerate}
\usepackage{wasysym}
\usepackage{lipsum}
\usepackage{amssymb}
\usepackage{amsthm}

\usepackage{hyperref}


%\setlength{\oddsidemargin}{.25in}
%\setlength{\evensidemargin}{.25in}
%\setlength{\textwidth}{6in}
%\setlength{\topmargin}{-0.4in}
%\setlength{\textheight}{9.5in}

\newtheorem{theorem}{Theorem}



\begin{document}

\begin{theorem}
    My Tex does work now
\end{theorem}


\end{document}
Related Question