%% Source code listings
%% takata.yoshiaki@kochi-tech.ac.jp, Mar. 2014.
%%
%% This LaTeX code puts source code listings to landscape papers,
%% using listings.sty.
%% Use the following command for producing landscape pages:
%% $ dvipdfmx -l list.dvi
%%
%% The manual of listings.sty can be found in the follwing URL.
%% http://www.ctan.org/tex-archive/macros/latex/contrib/listings/listings.pdf
%% (Note that I'm not sure whether or not the listings.sty supports
%% source codes with Japanese characters.)
%%
\documentclass[a4j,landscape,twocolumn]{jarticle}
\usepackage{listings}
\usepackage{color}

%% Syntax highlighting colors, following the Eclipse default settings.
\definecolor{jred}{rgb}{0.5,0.0,0.33}
\definecolor{jgreen}{rgb}{0.25,0.5,0.37}
\lstset{
  language=Java,
  basicstyle=\footnotesize\ttfamily,
  columns=flexible, % use natural width of the characters
  keywordstyle=\color{jred},
  commentstyle=\color{jgreen}
}

%% Extend the paper size a little.
\addtolength{\textwidth}{10mm}
\addtolength{\oddsidemargin}{-5mm}
\addtolength{\textheight}{5mm}
\addtolength{\topmargin}{-5mm}

%% Page nombre
\renewcommand{\thepage}{A-\arabic{page}}

%% \appendix
\let\origappendix=\appendix
\renewcommand{\appendix}{\par
  \begin{flushleft}\LARGE\bfseries Appendix\end{flushleft}\origappendix}

\begin{document}

\appendix
\section{Source code of the program}

\subsection{ImageMonochromatizer.java}
\lstinputlisting{java/ImageMonochromatizer.java}

\newpage
\subsection{ImageColorModifier.java}
\lstinputlisting{java/ImageColorModifier.java}

\newpage
\subsection{ImageProcessor.java}
\lstinputlisting{java/ImageProcessor.java}

\end{document}
