Math & ScienceLabel for Theorem in custom Class

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
dejan85
Posts: 8
Joined: Sat Nov 08, 2008 3:14 pm

Label for Theorem in custom Class

Post by dejan85 »

I need to put \label in the {theorem} environment like this:

Code: Select all

\documentclass{article}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem}
This is Theorem.
\label{label}
\end{theorem}
\end{document}
I am writing to IJPRAI journal and I must use their style. When I change the style

Code: Select all

\documentclass{ws-ijprai}

\begin{document}
\begin{theorem}
This is Theorem.
%\label{label}
\end{theorem}
\end{document}
I got error if I uncomment the label command

Code: Select all

! Undefined control sequence.
<write> \newlabel{label}{{\p@Theorem 
                                     \theTheorem }{\thepage }}
I read their instruction file and they don't write how to label theorem.
They probably have predefined theorem environment which does not allow putting label inside theorem. Does anybody know how to solve the problem? I attached their file style.
Attachments
ws-ijprai.cls
(38.63 KiB) Downloaded 286 times

Recommended reading 2024:

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

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Label for Theorem in custom Class

Post by cgnieder »

There is a bug in the class in the way it defines \newtheorem. I found a possible workaround which is not very robust. A better way would be to actually fix the definition.

Use with care:

Code: Select all

\documentclass{ws-ijprai}
\usepackage{etoolbox}

\makeatletter
\patchcmd\@opargbegintheorem
  {\@currentlabel{\csname p@#1\endcsname\csname the#1\endcsname}}
  {\lowercase{\@currentlabel{\csname p@#1\endcsname\csname the#1\endcsname}}}{}{F}
\makeatother

\begin{document}

\begin{theorem}
This is Theorem.
\label{label}
\end{theorem}

\ref{label}

\end{document}
Regards
site moderator & package author
Post Reply