Add code-related things to LaTeX document template

This commit is contained in:
Talia 2019-11-27 18:24:33 +01:00
parent ec405ec8a8
commit 798389f630
No known key found for this signature in database
GPG key ID: AD727AD22802D0D6

View file

@ -1,15 +1,41 @@
\documentclass{article} \documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage{graphicx} \usepackage{graphicx}
\usepackage[backend=biber,style=alphabetic]{biblatex} \usepackage[backend=biber,style=alphabetic]{biblatex}
\addbibresource{$HOME/me/bibliotheca.bib} \addbibresource{$HOME/me/bibliotheca.bib}
\def\code#1{\texttt{#1}}
\title{Programming is fun!} \title{Programming is fun!}
\author{DarkWiiPlayer} \author{DarkWiiPlayer}
\definecolor{listingbg}{rgb}{1,0.96,0.7}
\begin{document} \begin{document}
\lstset{
backgroundcolor=\color{listingbg},
tabsize=3, numbers=left,
}
\maketitle \maketitle
Listings can be done fairly easily in LaTeX; one only has to include the \code{listings} package and start a new \code{lstlisting} block.
\lstset{language=[5.1]Lua,caption={A hello world program in Lua}}
\begin{lstlisting}
-- Comment
print "Hello World!"
\end{lstlisting}
\lstset{language=C,caption={The same program in C}}
\begin{lstlisting}
#include <stdio.h>
// Comment
int main() { printf("Hello World!\n") }
\end{lstlisting}
\begin{figure}[h] \begin{figure}[h]
\centering \centering
\includegraphics{$HOME/image.png} \includegraphics{$HOME/image.png}