[Tex/LaTex] Display appendix section title like “Appendix A My Code Listing”

appendiceskoma-scriptnumberingsectioning

I'm using the document class scrartcl and appendix. This currently results in a letter instead of a number for section enumeration in the TOC and section title ("A My Code Listing").
I need to change this to "Appendix A My Code Listing", i.e. add the word "Appendix" to the section title.

I have found a manual workaround on http://web.reed.edu/cis/help/latex/thesis#appendices but would like to know if there is a way to change this automatically.

Best Answer

\documentclass[toc=left]{scrartcl}

\begin{document}
\tableofcontents

\section{foo} bar

\appendix
\gdef\thesection{Appendix \Alph{section}}
\section{foo} bar
\section{foo} bar

\end{document}