1

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}
\addcontentsline{toc}{section}{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
1

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:

Sample output

\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}
\addcontentsline{toc}{section}{Anhang}
\begin{code}
...
\end{code}
\end{document}
  • Thanks for your answer. If I use this code it still shows the section number of the Apeendix in the Header. How can I get rid of that? – little_miss_sunshine Nov 29 '13 at 11:22
  • The above code produces no header, so you will have to tell us how you make your headers. That is probably best done as a separate question. But have a look around this site for related questions. – Andrew Swann Nov 29 '13 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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