1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
\documentclass[a4paper, 12pt]{article}
\usepackage{times}
\usepackage{listings}
\usepackage{color}
\definecolor{grey}{rgb}{0.95,0.95,0.95}
%%%%%%%%%%%%%%%%%%%%%%%%%%%% Custom Code Formatting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - 1 PHP
\lstnewenvironment{phpcode}[1][]
{\lstset{language=PHP, basicstyle=\scriptsize\ttfamily,
tabsize=2, breaklines=true, numberstyle=\tiny,
numbers=left,
numbersep=10pt, stepnumber=1,
xleftmargin=12mm,
frame=leftline,
framerule=4pt,
rulecolor=\color{green},
commentstyle=\color{blue},
keywordstyle=\color{red}\bfseries,
showspaces=false,
showstringspaces=false,
#1}
}
{}
\begin{document}
\title{Code Formatting Test}
\author{Aramis}
\date{}
\maketitle
\begin{abstract}
\noindent Let's try to have multiple type of source codes, or shell output, and format them easily in \LaTeX{}.
\end{abstract}
\section{PHP Code Example}
\label{sec:phpexample}
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
\begin{phpcode}[caption={Example of Code for PHP}, label=lst:php]
<?php
// Hello World in PHP
echo 'Hello World!';
?>
<?
// Hello World in PHP + GD library
header("Content-type: image/gif");
$rscImage = imagecreatetruecolor(80, 25);
$intFontC = imagecolorallocate($rscImage, 255, 255, 255);
$intBGC = imagecolorallocate($rscImage, 0, 0, 0);
imagestring($rscImage, 2, 5, 5, "Hello World!", $intFontC);
imagegif($rscImage);
imagedestroy($rscImage);
?>
\end{phpcode}
\end{document} |
Partager