I have some code to generate random graphs:
\documentclass{article}
% code hijacked from: https://gist.github.com/fgrosse/5807324
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage{fancyhdr}
\definecolor{blueish}{rgb}{0.565,0.886,1} % blue-ish
\definecolor{greenish}{rgb}{0.565,1,0.886} % green-ish
\definecolor{darkgray}{rgb}{0.15,0.15,0.15} % very dark gray
\definecolor{lightgray}{rgb}{0.6,0.6,0.6} % light gray
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\makeatletter
\newcommand{\canvaswidth}{12}
\newcommand{\canvasheight}{12}
\newcommand{\gettikzxy}[3]{ % I got this from https://tex.stackexchange.com/questions/33703/extract-x-y-coordinate-of-an-arbitrary-point-in-tikz
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}
\edef#3{\the\pgf@y}
}
\makeatother
\tikzstyle{circlenode}=[circle, draw=blueish]
\tikzstyle{boxnode}=[rectangle, draw=greenish]
\pgfmathsetseed{\number\pdfrandomseed}
\begin{document}
\pagecolor{darkgray}
\color{blueish}
\begin{tikzpicture}
\pgfmathparse{random(20, 40)}
\pgfmathtruncatemacro\nrOfNodes{\pgfmathresult}
\foreach \i in {1,...,\nrOfNodes} {
\pgfmathsetmacro\posX{rnd*(\canvaswidth)}
\pgfmathsetmacro\posY{rnd*(\canvasheight)}
\pgfmathparse{random(1, 3)}
\pgfmathtruncatemacro\nodetype{\pgfmathresult}
\ifnum\nodetype>1
\node[circlenode] (a\i) at (\posX, \posY) {};
\else
\node[boxnode] (a\i) at (\posX, \posY) {};
\fi
\pgfmathparse{random(60, 80)}
\pgfmathtruncatemacro\diameter{\pgfmathresult}
\begin{pgfonlayer}{background}
\draw[color=black,fill=blue, opacity=0.05] (a\i) circle (\diameter pt);
\end{pgfonlayer}
% draw node connections
\ifnum\i>1
\pgfmathsetmacro\last{\i -1}
\foreach \j in {1,...,\last} {
\gettikzxy{(a\i)}{\pX}{\pY};
\gettikzxy{(a\j)}{\qX}{\qY};
% divide by 100 so the values are still small enough for tickz to handle while preserving adequate precision
\pgfmathsetmacro\diffX{(\pX-\qX)/100}
\pgfmathsetmacro\diffY{(\pY-\qY)/100}
\pgfmathsetmacro\calculatedDistance{ sqrt( (\diffX)^2 + (\diffY)^2 ) * 100};
\ifdim\calculatedDistance pt <\diameter pt
\begin{pgfonlayer}{background}
\draw[lightgray] (a\i) -- (a\j) node [midway, above, sloped] {};
\end{pgfonlayer}
\fi
}
\fi
}
\end{tikzpicture}
\end{document}
It produces output like:
I also have some code to produce some sample text with math (it has the same "header content" as the graph code):
\documentclass{article}
% code hijacked from: https://gist.github.com/fgrosse/5807324
\usepackage[utf8x]{inputenc}
\usepackage{concmath}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage{fancyhdr}
\definecolor{blueish}{rgb}{0.565,0.886,1} % blue-ish
\definecolor{greenish}{rgb}{0.565,1,0.886} % green-ish
\definecolor{darkgray}{rgb}{0.15,0.15,0.15} % very dark gray
\definecolor{lightgray}{rgb}{0.6,0.6,0.6} % light gray
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\makeatletter
\newcommand{\canvaswidth}{12}
\newcommand{\canvasheight}{12}
\newcommand{\gettikzxy}[3]{ % I got this from https://tex.stackexchange.com/questions/33703/extract-x-y-coordinate-of-an-arbitrary-point-in-tikz
\tikz@scan@one@point\pgfutil@firstofone#1\relax
\edef#2{\the\pgf@x}
\edef#3{\the\pgf@y}
}
\makeatother
\tikzstyle{circlenode}=[circle, draw=blueish]
\tikzstyle{boxnode}=[rectangle, draw=greenish]
\pgfmathsetseed{\number\pdfrandomseed}
% ==================================================
\makeatletter
\fancypagestyle{scifi}{%
\fancyhf{}% Clear header/footer
\fancyfoot[C]{\textcolor{blueish}{\thepage}}% Page # in middle/centre of footer
}
\makeatother
% ==================================================
\pagestyle{scifi}
\begin{document}
\pagecolor{darkgray}
\color{blueish}
\title{A test sci-fi document}
\date{2958.16.32}
\maketitle
\reversemarginpar
% -----------------------------------------
\begin{enumerate}
\item How many errors can each of the following codes detect/correct? (assuming NND decoder)
\begin{enumerate}
\item $\mathcal{C} = \{000000, 111111, 000111\}, q = 2$
Computing the minimum distance between any two code words:
\begin{center}
\begin{tabular}{c|c|c|c}
& $000000$ & $111111$ & $000111$ \\
\hline
$000000$ & $0$ & & \\
\hline
$111111$ & $6$ & $0$ & \\
\hline
$000111$ & $3$ & $3$ & $0$ \\
\end{tabular}
\end{center}
Since the minimum distance between code words is $3$:
\begin{align*}
&u \leq d - 1 \\
&u \leq 3 - 1 \\
&u \leq 2 \\
& \\
&v \leq \lfloor\frac{d - 1}{2}\rfloor \\
&v \leq \lfloor\frac{3 - 1}{2}\rfloor \\
&v \leq 1
\end{align*}
So, this code can correct $1$ or less errors, and can detect $2$ or less errors.
\end{enumerate}
\end{enumerate}
\end{document}
It produces output like this:
I tried to use the answer to this question Is it possible to use tikz to draw a background on the printed page? in order to put the random graph as the background of the text, but I ran into various compile errors, likely caused due to syntax errors, and so on.
So, rather than enumerate all those pointless errors, can I ask instead: how should I go about combining these two documents? In particular, should I skip using the backgrounds
package?