Skip to content

Instantly share code, notes, and snippets.

@sgmonda
Last active April 3, 2021 00:29
Show Gist options
  • Save sgmonda/96941051845f4430989454f1f208ada2 to your computer and use it in GitHub Desktop.
Save sgmonda/96941051845f4430989454f1f208ada2 to your computer and use it in GitHub Desktop.
Simple LaTeX template to print beautiful black&white Javascript source code
\documentclass[a4paper, 12pt]{article}
\usepackage[letterpaper, margin=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{beramono}
\usepackage{listings}
\usepackage{xcolor}
\newcommand\realnumberstyle[1]{}
\makeatletter
\makeatother
\lstset{
aboveskip=0cm,
stringstyle=\ttfamily,
showstringspaces = false,
basicstyle=\scriptsize\ttfamily,
commentstyle=\color{gray!45},
keywordstyle=\bfseries,
ndkeywordstyle=\bfseries,
identifierstyle=\ttfamily,
numbers=left,
numbersep=15pt,
numberstyle=\tiny,
numberfirstline = false,
breaklines=true
}
\lstdefinelanguage{JavaScript}{
keywords={typeof, new, true, false, catch, function, return, null, catch, switch, var, const, let, async, await, if, in, while, do, else, case, break, from},
ndkeywords={class, export, boolean, throw, implements, import, this},
sensitive=false,
comment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]"
}
\begin{document}
\begin{lstlisting}[language=JavaScript,numbers=left]
Paste your code here
\end{lstlisting}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment