[Tex/LaTex] Formatting the SQL-like script

formattingsourcecode

Suppose we have a script as follows:

a = LOAD 'data' USING BinStorage AS (user);
b = GROUP a BY user;
c = FOREACH b GENERATE COUNT(a) AS cnt;
d = ORDER c BY cnt;

How to write the latex code to achieve the following effect:
enter image description here

Best Answer

I believe that a simple verbatim environment will suffice.

\documentclass{article}

\begin{document}
\begin{verbatim}
a = LOAD `data' USING BinStorage AS (user);
b = GROUP a BY user;
c = FOREACH b GENERATE COUNT(a) AS cnt;
d = ORDER c BY cnt;
\end{verbatim}
\end{document}

Output:

enter image description here

Notice that we have to use the left single quote ` and right single quote ' characters marks to get the right quotation marks.

Related Question