For example, in the figure below, I want to change the chapter entry in TOC to Chapter 1. Introduction.

and the same goes for the appendix entry in TOC, which means typesetting Appendix A. Electro... instead of the figure below.

Additionally, I have used \appendix before starting my appendices, so it treats all the subsequent chapters as chapters A, B, etc. However, I want to treat them as appendices to appear correctly in the page headings as "Appendix A. Electro..." instead of "Chapter A. Electro..." in the page heading as shown below.

-

Your first question can be solved by using the tocstyle-package included in the KOMAscript-bundle. Try

 texdoc tocstyle


at an command prompt to see the documentation.

By redefining some internal variables, if I understand your question correctly, you will have the answer to your first question. Put this commands in your preamble:

\usepackage{tocstyle}
}
\usetocstyle{KOMAlike}


However, I want to treat them as appendices to appear correctly in the page headings as "Appendix A. Electro..."

This be solved by using the class-option chapterprefix=true or appendixprefix=true, if I understand your question correctly.

A complete MWE, which (hopefully) solve all questions:

\documentclass[appendixprefix=true]{scrbook}
\usepackage{blindtext}
\usepackage{tocstyle}
}

\usetocstyle{KOMAlike}

\begin{document}
\tableofcontents
\blinddocument
\appendix

\blinddocument

\end{document}


If you are using \chapter in \fronmatter, remember to use the starred version to avoid a Chapter . with empty number in your Table of Contents. Also, if you are using the command \addchapin you document, use the starred version (\addchap*}.

For further reading, see page 80 in the English manual, and this discussion at the KOMAscript homepage.

NB! This code needs a recent version of komascript.

-
Thanks for help, but the MWE doesnt work and I got this "! LaTeX Error: \addchaptertocentry undefined." – Diaa Abidou Jul 7 '12 at 1:32
Strange, The MWE works on my system (updated MikTeX on Win 7). What is your version of koma-script? – Sveinung Jul 7 '12 at 7:44
After updating the Miktex 2.9 packages, the same error appears. Regarding the Koma version, here is the line from log file: Document Class: scrbook 2010/09/17 v3.07 KOMA-Script document class (book – Diaa Abidou Jul 7 '12 at 18:12
@Diaa Current version of komascript is 3.11a. My scrbook reports: scrbook 2012/05/15 v3.11 KOMA-Script document class (book). If your miktex that does not update your packages correctly, or maybe you have a copy of scrbook in your texmf-local (or whatever you have named your private TeX directory). The code need a recent version of komascript. – Sveinung Jul 7 '12 at 20:22
I fixed it by removing the option "bibliography=totoc" and inserting "\addcontentsline{toc}{chapter}{References}" after \bibliography{<bibfile.bib>}. If available, can you tell me why does this awkward entry appear in case of using the class option ? – Diaa Abidou Jul 9 '12 at 0:36

Thanks to the answer of the question \chaptername is used even for appendix chapters in ToC

the syntax of

\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
\makeatletter
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
}%
}
\makeatother


has a successful result in prefixing the chapters entries in TOC with the word "Chapter" (same for appendices).

For the running headings in the in the appendices environment, the following syntax changes

Chapter to Appendix

\begin{document}

\appendix
\renewcommand{\chaptermark}[1]{\markboth{Appendix\ \thechapter.\ #1}{}}
\chapter{Appendix A}
\chapter{Appendix B}

\end{document}

-

Here is a suggestion that also works if you are using chapters in frontmatter or options like listof=toc or \addchap.

\documentclass[
chapterprefix,
%numbers=noenddot,
%toc=indentunnumbered,
listof=totoc,
%listof=chapterentry
]{scrbook}

\usepackage[english]{babel}

\ifstr{#1}{}{%
\addtocentrydefault{chapter}{\chapapp{} #1}{#2}%<- numbered chapters in TOC
}}

\RedeclareSectionCommand[
tocnumwidth=6em% <- space for the chapter number in TOC
]{chapter}

\usepackage{blindtext}
\begin{document}
\frontmatter
\tableofcontents
\listoftables
\chapter{This is a chapter in frontmatter}
\mainmatter
\blinddocument
\begin{table}%
\begin{tabular}{l}
\Huge X
\end{tabular}
\caption{A table}
\end{table}