# Numbering theorems in the appendix by adding the appendix letter in front/after the theorem number

Can someone please tell me how to make definitions, theorems etc. in the appendix look like Definition A1 or Definition 1A (an "A" should be somewhere), if the appendix is "numbered" with A (meaning latex shows A Appendix, if I compile the document). Right now all the definitions, theorems etc.are numbered from 1 to n, where n is the last definition, theorem etc. of my document (sections don't change the numbering), even if this last one is in the appendix.

Equation numbering is ok though; the first numbered equation is "A.1".

The thing is, I'm using LyX, so I would prefer it, if there were some command that I could use to reset the counter and globally change the look of definitions, theorems etc. in the appendix, so that I

1) don't have to remove all the LyX-created environments (like for example the LyX-created definition environment) and replace them by hand-coded ones in order to maybe pass some additional arguments to each them, because that looks horrible in LyX.

2) don't have to use a different way to insert the appendix other then the one LyX provides and that is via \appendix (not via the appendix package).

FYI: I'm using LyX 2; the document class is article; my appendix is situated after several sections (I don't used any other divisioning of my document like subsections etc. - if that makes any difference).

-

Add the following code to the preamble settings of your LyX document:

\usepackage{chngcntr}


In the document body, add the following "Evil Red Text" (LaTeX code) immediately after \appendix to effect the desired change for an environment called thm:

\counterwithin{thm}{section}
% \renewcommand{\thethm}{\thesection\arabic{thm}}% optional


You'll have to check your preamble for the existing theorem-like environments and their names (AFAIK, this depends on the loaded LyX modules) and apply the above code for every environment.

Here's a compilable example:

\documentclass{article}

\newtheorem{thm}{Theorem}

\usepackage{chngcntr}

\begin{document}

\section{First}

\begin{thm}
A theorem.
\end{thm}

\section{Second}

\begin{thm}
Another theorem.
\end{thm}

\appendix

\counterwithin{thm}{section}
% \renewcommand{\thethm}{\thesection\arabic{thm}}% optional

\section{App-First}

\begin{thm}
An appendix theorem.
\end{thm}

\section{App-Second}

\begin{thm}
Another appendix theorem.
\end{thm}

\end{document}

-