Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I write my bachelor thesis using a document class provided by our institute based on scrbook. I write pseudo-codes using algorithm2e which I put in the appendix since otherwise they would "interrupt" reading the text where I refer to them (they cover 4 pages).

My thesis has 7 chapters, excluding References and Appendix. The algorithms are numbered in their caption as 7.1, 7.2 and so on. I want them to be numbered 1, 2, ...

After googling, I found out how to add chapter numbers to the captions, however, I didn't write any of this (by myself, at least). How can I tell algorithm2e not to include the chapter numbers, as the appendix shouldn't be treated as part of my last chapter?

As chapter numbers may have been explicitly enabled in the document class I'm using: Which command(s) in the class file can be the problem? Note that all types of floats with captions (figures, theorems, ...) have a chapter number (but this is OK in general, except for my algorithms in the appendix).

I use the following options:

\usepackage[ruled,vlined,linesnumbered]{algorithm2e}
share|improve this question
1  
Welcome to TeX.sx!. –  Andrew Swann Nov 13 '12 at 19:11
    
@AndrewSwann thank you very much ;) –  leemes Nov 13 '12 at 19:13

1 Answer 1

Without a MWE or your custom class, using the chngcntr package to reset the counter \algocf@float (indeed, a macro) after the last chapter may do the trick.

\documentclass{scrbook}

\usepackage{algorithm2e}

\usepackage{chngcntr}

\makeatletter
\counterwithin{\algocf@float}{chapter}% maybe part of your custom class

\newcommand*{\algowithoutchap}{%
  \counterwithout{\algocf@float}{chapter}%
}
\makeatother

\begin{document}

\chapter{foo}

Some text.

\chapter*{Appendix}

\algowithoutchap

\begin{algorithm}
  \uIf{1}{if...}%
  \Else{else... \\ \If{1}{if...}}%
\caption{An algorithm}
\end{algorithm}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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