Add code-related things to LaTeX document template
This commit is contained in:
parent
ec405ec8a8
commit
798389f630
1 changed files with 26 additions and 0 deletions
|
@ -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}
|
||||||
|
|
Loading…
Reference in a new issue