# Number of newtheorem overlaps with newtheorem in the Appendix

I have the following code:

\documentclass[a4paper,12pt]{article}
\renewcommand{\proofname}{\textbf{Beweis}}
\newtheorem{Satz}{Satz}[section]
\newtheorem{code}[Satz]{MATLAB-Code}

\begin{document}

\section*{Anhang}
\renewcommand\thesection{\hspace{-1em}}
\sectionmark{Anhang}
\begin{code}
...
\end{code}
\end{document}


The problem is that the number of the code overlaps with the word MATLAB-Code in the appendix (Anhang). I guess it has something to do that there is no section number for the appendix. How can I fix that? If I write

\newtheorem{code}{MATLAB-Code}


then the number of the newtheorem and the word MATLAB-Code don't overlap, but then the codes get numberes from 1 on instead of using the section number. Thanks a lot!!!

• Can provide a working example illustrating the problem. Removing [Satz] from the above code makes it compilable, but also does not show any problem with overlapping numbers. – Andrew Swann Nov 27 '13 at 13:44
• I did exact the same for \newtheorem{Bem}[Satz]{Bemerkung} and there it works. My guess is that MATLAB-Code is too long. – little_miss_sunshine Nov 27 '13 at 13:47
• There is something you are not telling us. This includes something in the document sets up the count Satz, and possibly theorem related packages you are loading... – Andrew Swann Nov 27 '13 at 13:50
• you are right, if i delete [Satz] it's working. That's exact how I wanted it, thanks. – little_miss_sunshine Nov 27 '13 at 13:52
• But then the number of MATLAB-code starts with one, but I want that the number is the chapter number.1, chapter number.2 and so on. – little_miss_sunshine Nov 27 '13 at 13:59

You ask how remove section numbers of theorem like items in the appendix. Redefining \thesection to \hspace{-1em} causes you many problems as you found out.

Instead to remove section numbering of these elements in the appendix use the chngcntr packages's function \counterwithout:

\documentclass[a4paper,12pt]{article}

\usepackage{chngcntr}

\newtheorem{Satz}{Satz}[section]
\newtheorem{code}[Satz]{MATLAB-Code}

\begin{document}

\section{A section}

\begin{Satz}
Theorem text.
\end{Satz}

\section*{Anhang}

\counterwithout{Satz}{section}
\sectionmark{Anhang}